3 ms·
Not to be picky, but still not good enough: echo '1 2 3 4' | cut -d' ' -f2 'cut' fails when fields are separated by multiple spaces.
by nimrody 16y ago
Not to be picky, but still not good enough:
echo '1 2 3 4' | cut -d' ' -f2
'cut' fails when fields are separated by multiple spaces.
- pmarin 16y agoOk. > echo '1 2 3 4' | sed 's/ */\t/g' | cut -f2 2
- molinari 16y agoI usually pipe through a whitespace-to-single-tab command. So echo '1 2 3 4' | sp2tab | cut -f2 would be equivalent to echo '1 2 3 4' | awk '{print $2}' but quicker to write.
- deleted 16y ago[deleted]
- Kototama 16y agoecho "1 2 3 4" | tr -s " " | cut -f1 -d " " tr is nice!
- cma 16y agoDoesn't work, gets caught on leading spaces: echo ' 1 2 3 4' | tr -s " " | cut -f1 -d " " > echo ' 1 2 3 4' | awk '{print $1}' >1