2

I have used the uniq -c command, but now I don't have a need for that information. How can I cut/delete that field?

I tried to read online about the cut command, but I simply didn't understand..

Enter image description here

I simply want this output, without the first field from the left...

  • 7
    just don't use -c. – cuonglm Nov 30 '16 at 11:35
  • but i needed the -c. now i need to delete it – Michael Segal Nov 30 '16 at 11:37
  • Don't post images of text. – Tomasz Jan 9 '17 at 22:42
8
awk '{print $2}' new-word-freq.txt
  • 3
    Note that it prints the second sequence of non-blank characters of each line in the input, which does more than removing the text added by uniq -c, if the original text contained blanks (would be OK for a list of words one per line as the name of the file and the OP's sample suggest though). – Stéphane Chazelas Nov 30 '16 at 11:52
  • 1
    Great! very simple and straight forward – Michael Segal Nov 30 '16 at 11:54
10

If the output is as generated by GNU uniq at least, where the lines consist in a sequence of 0 or more space characters, a decimal number, a single space character and the content of the original line, then you can do:

sed 's/^ *[0-9]\{1,\} //' < file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.