[ACCEPTED]-Using cut with unprintable delimiters-command-line

Accepted answer
Score: 30

If you're using Bash,

cut -d $'\001' ...

works (see Bash Reference Manual # ANSI-C Quoting).

Other 6 (more portable) options,

cut -d `echo -e '\001'` ...

FS=`echo -e '\001'`
cut -d $FS ...

or inserting the 5 control character directly using ^V as mentioned 4 by Alnitak and etlerant -- on the shell 3 command line, and in editors such as vi, this 2 means "don't treat the next thing I 1 type specially".

Score: 6

Yes, it's perfectly possible.

If typing in 4 a shell, press ^V and then ^A to insert the 3 ^A verbatim in the current line rather than 2 have it treated as the normal 'go to start 1 of line' command:

% cat -v foo
% cut -d^A -f2 foo
Score: 1

If for example you unprintable delimiter 3 is tab which is equivalent of \t and you want 2 to find the second to the end item of each 1 line separated by tab you can use this:

cut -d $'\t' -f2- tablimited.csv
Score: 0



More Related questions