pacman pacman - 4 months ago 16x
Linux Question

Using cut with unprintable delimiters

Is it possible to use cut and have unprintable characters be the delimiter? For example I'd like to have the "^A" characters (also represented as \001) be the delimiter.


If you're using Bash,

cut -d $'\001' ...

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

Other (more portable) options,

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

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

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