LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   how to delete different column in a file? (https://www.linuxquestions.org/questions/programming-9/how-to-delete-different-column-in-a-file-516101/)

Tuku 01-04-2007 12:07 AM

how to delete different column in a file?
 
I am new to Linux. I have the foollowing information in a file and I have to delete the 2nd and third column. Please tell me how can I do it?

ft0.fm2.fail | 3Dh | ok | 29.2 | Predictive Failure Deasserted
ft1.fm0.fail | 3Eh | ok | 29.3 | Predictive Failure Deasserted
ft1.fm1.fail | 3Fh | ok | 29.4 | Predictive Failure Deasserted
ft1.fm2.fail | 40h | ok | 29.5 | Predictive Failure Deasserted
ft0.fm0.f0.speed | 41h | ok | 29.0 | 10000 RPM
ft0.fm1.f0.speed | 42h | ok | 29.1 | 9000 RPM
ft0.fm2.f0.speed | 43h | ok | 29.2 | 10000 RPM
ft1.fm0.f0.speed | 44h | ok | 29.3 | 11000 RPM
ft1.fm1.f0.speed | 45h | ok | 29.4 | 11000 RPM
ft1.fm2.f0.speed | 46h | ok | 29.5 | 10000 RPM
ft0.fm0.f1.speed | 47h | ok | 29.0 | 9000 RPM

thanks
-Tuku-

PatrickNew 01-04-2007 12:23 AM

First, you posted in the wrong forum. You probably want ot go to a sub-forum called programming. Probably the easiest solution to your problem is to write a small bash script. Just google "bash script tutorial" and you'll get flooded.

Tinkster 01-04-2007 01:49 AM

Odd forum to ask this question, indeed, but here's one
possible solution.
Code:

awk -F"|" '{print $1"|"$4"|"$5}' datafile

Cheers,
Tink

jeremy 01-04-2007 09:53 AM

I've moved your thread. Is there anything we could have done to make it clearer that the forum you originally posted this in was only for feedback about LQ itself? Your answer may help improve LQ.

--jeremy


All times are GMT -5. The time now is 02:59 PM.