2 ms·
>cut doesn't work with fields separated by arbitrary whitespace. It's often better to use awk I was working on a script to provide cut like syntax using awk, m
by asicsp 5y ago
>cut doesn't work with fields separated by arbitrary whitespace. It's often better to use awk
I was working on a script to provide cut like syntax using awk, mainly for awk's default field separation and regexp delimiters. It isn't ready, but I just created a repo with what I have so far: https://github.com/learnbyexample/regexp-cut https://github.com/learnbyexample/regexp-cut
- theiasson 5y agoNice tool. I just found that if you have fields separated by arbitrary whitespaces, piping that through xargs trims multiple whitespaces into a single whitespace. ```$ echo "words are far apart" | xargs``` Although, it does have its caveats. https://stackoverflow.com/a/12973694 https://stackoverflow.com/a/12973694
- unhammer 5y ago>cut doesn't work with fields separated by arbitrary whitespace. It's often better to use awk I use `cut` precisely when I want this behaviour. If something actually is tab-separated, I don't want `cut -f3` to give me the 4th column just because the value in column 1 was the empty string.