4 ms·
cut -f1
by robertduncan 16y ago
cut -f1
- johnrob 16y agoNot working for me... > echo '1 2 3 4' | awk '{print $1}' 1 > echo '1 2 3 4' | cut -f1 1 2 3 4
- pmarin 16y agoecho '1 2 3 4' | cut -d' ' -f1 By default cut uses TAB as delimiter
- nimrody 16y agoNot 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