acut (1) Gets parts of a file (Jul-2016)
acut also allows to translate (replace characters) in specified columns (T), and to remove leading and/or trailing blanks in specified columns (h, j and t), or to perform regular expression substitution in the specified columns.
acut is especially useful for reformatting decimal or sexagesimal numbers which can be properly aligned (see below). Accepted sexagesimal representations include blank- or column-separated numbers (like 12:04:56 or 12 04 56), as well as number without separator (like 120445)
–version prints the version and exits.
–Ccomment defines comment lines – lines starting by comment are just copied to the output without reformatting. For instance, –C'#' will consider lines starting by a has sign as comments. By default, blank lines are considered by comments.
–dc defines the character used as a delimiter between columns; this delimiter is only used in cunjunction with the -f option. Its default is the tab.
–el asks to process the empty lines. By default the empty lines are directly issued, assuming these have just a role of delimiter. (added in V3.92)
–T s1 s2 defines the translation table: characters from s1 are converted into the corresponding characters of s2 (byte-by-byte translation). Strings s1 and s2 must have the same length. The complete alphabet may be specified by \a (lowercase) or \A (uppercase); \s stands for the 6 spaces (blank, tab, vtab, newline, carriage-return, form-feed) Non-printable characters can be specified using the C conventions (e.g. \n for the newline, or \e for the Escape, or the octal representation).
As a shortcut, acut accepts the options –Tlow and –Tup for conversion to lowercase / uppercase.
–acols
asks to insert a delimiter (the character defined by
the –dc option) between character columns;
for example, acut -a1-15,16- inserts a tab between
bytes 15 and 16.
Note that only one –a option can be specified.
–ccols defines a set of character columns. cols expressions can make use of commas and dashes, e.g. -c1,80,2-5 asks to pick successively the columns 1, then 80, then the range 2 to 5. cols may be empty, meaning all consecutive columns between the previous –c and next –c definitions. For details on how cols can be written, refer to the cols section.
–fcols is similar to the –c option, but columns are defined as the set of bytes between two delimiter characters.
–itext to insert the fixed text following the –i into each line of the output. The –i alone asks to insert the delimiter (specified by the –d option, tab by default)
–imap mapping_expression to combine in a single argument a mixture of text (–i) and column exceprts (–f or –c, depending whether a delimiter character was defined via the –d option). In this mode, the $ (or @) is used to specify excerpts, either as $n (where n represents a number) for the column number n ($1 is the leftmost columns, while $0 represents the whole line), or as a cols expression within curly braces like ${expr}.
There is however a difference between -f5-10 and -f5+6: the former (-f5-10 consists of the 5 columns separated by 4 delimiters (the character defined by the –d option), while the latter -f5+6 has no delimiter between the 5 columns (the 5 columns are concatenated). An alternative way of concatenating the character-separated columns is to start the list of fields with a – (minus), e.g. -f5+6 and -f-2-10 are equivalent.
A missing number after the dash means up to end of line, and a missing number before the dash means from byte following the last defined column. A repetition factor can be added, e.g. -c5+6*4 to specify the 4 fields laying over bytes 5–10, 11–16, 17–22 and 23–28.
cols may also be
cols expressions may end with the following reformatting options:
For instance, translating the first column in uppercase and removing leading & trailing blanks in the other columns can be written as
-T a-z A-Z -f1T -f2-j
In this option, the following transformations are performed:
0123456789 0123456789 - 12 -12. 12.2: 12.2 : <10? < 10. ?When the alignment is not possible or a truncation occured, a warning message is issued.
acut -c1-12s'/ //g' -c13-
or squeezing the blanks (leaving just one when there are several)
acut -c1-12s'/ */ /g' -c13-
The substitution can use the \1 ... patterns matched as in sed: for instance interverting the texts separated by a comma between columns 1 and 12 can be written
acut -c1-12s'^/\([^,]*\),\(.*\)/\2,\1/'
The complete option is +n[a|A|d|x|o] where: