Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a really large text file (~80 Million records/lines), where each record has 7 attributes. Between every attribute there is a tab.

What I want to do is copy every third and last attribute/token of every record/line at a new file.

Any ideas how I could do that with the cut command?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

A good starting point would be:

cut -f 3,7 input.txt > output.txt

If the file isn't tab delimited, you'll need to add a -d switch with the delimiter ( -d. would be a . delimited file).

Here are some examples, including grabbing multiple fields: http://linux.101hacks.com/linux-commands/cut-command-examples/

share|improve this answer
    
You beat me to it. –  Ansgar Wiechers Oct 13 '12 at 23:39
    
Is there any way I could cut specific rows based on the numerical value of some attributes? For example cut every row's 3 and 7 column but only if the fifth attribute < 5. –  ddmichael Oct 31 '12 at 22:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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