7

I'm trying to use Unix cut to remove the first two fields per line. I have input lines of of the form

(token)(whitespace)(token)(lots of text)

The problem is that there exit n tokens per line, so I can't do something like this

cut -f3,4,5,6,7,8,9

Is there a way to tell cut to take everything except the specified fields?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Mike
  • 58,961
  • 76
  • 175
  • 221

4 Answers4

11
cut -d' ' -f3-

-d' ' might be required.

ring bearer
  • 20,383
  • 7
  • 59
  • 72
1
cut -f3-

[Body is too short? Is that new?]

Thomas
  • 174,939
  • 50
  • 355
  • 478
0

I tried the answer cut -d' '-f3- but it did not exclude the field. The below command worked though. I am using Linux SLES.

cut -d' ' -f3 --complement

Reference link https://www.commandlinefu.com/commands/view/6867/exclude-a-column-with-cut

Happy to be corrected and learn. Thank you.

BigHeadNelson
  • 73
  • 1
  • 4
-2

You can also use AWK for this:

   awk '{$1=$2=""}1' file
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
ghostdog74
  • 327,991
  • 56
  • 259
  • 343