LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-04-2007, 01:28 AM   #1
Tuku
LQ Newbie
 
Registered: Jan 2007
Posts: 3

Rep: Reputation: 0
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-
 
Old 01-04-2007, 01:43 AM   #2
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (Chicago area)
Distribution: Red Hat (8.0, RHEL5,6), CentOS, SuSE (10.x, 11.x, 12.2, 13.2), Solaris (8-10), Tru64, MacOS, Raspian
Posts: 1,108

Rep: Reputation: 64
Quote:
Originally Posted by Tuku
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

snip...

ft1.fm2.f0.speed | 46h | ok | 29.5 | 10000 RPM
ft0.fm0.f1.speed | 47h | ok | 29.0 | 9000 RPM

thanks
-Tuku-
The "cut" and "paste" utilities could be used for this (Boy, paste's a tool I havn't used in a while) but "awk" could be used for this as well and is probably simpler. Something like:
Code:
cat data.file | awk -F '|' '{print $1, "|", $4, "|", $5}'
where "data.file" is a file that contains the text you showed.

--
Rick
 
Old 01-04-2007, 01:47 AM   #3
Tuku
LQ Newbie
 
Registered: Jan 2007
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks.

-Tuku-
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to delete different column in a file? Tuku Programming 3 01-04-2007 10:53 AM
ripping a column from a text file dominant Linux - Newbie 1 01-31-2006 05:15 AM
How to delete a column in MySQL ? indian Linux - General 2 10-15-2004 02:02 PM
loading from text file using column width spyghost Programming 5 11-03-2003 02:34 PM


All times are GMT -5. The time now is 04:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration