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,030
  • 21
  • 100
  • 124
Mike
  • 56,266
  • 74
  • 170
  • 215

4 Answers4

11
cut -d' ' -f3-

-d' ' might be required.

ring bearer
  • 19,685
  • 7
  • 57
  • 70
1
cut -f3-

[Body is too short? Is that new?]

Thomas
  • 162,537
  • 44
  • 333
  • 446
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.

-2

You can also use AWK for this:

   awk '{$1=$2=""}1' file
Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
ghostdog74
  • 307,646
  • 55
  • 250
  • 337