printing first word in every line of a txt file unix bash

To print a whole word, you want -f 1, not -c 1. And since the default field delimiter is TAB rather than SPACE, you need to use the -d option.

cut -d' ' -f1 filename

To print the last two words not possible with cut, AFAIK, because it can only count from the beginning of the line. Use awk instead:

awk '{print $(NF-1), $NF;}' filename

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)