LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-04-2007, 12:07 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, 12:23 AM   #2
PatrickNew
Senior Member
 
Registered: Jan 2006
Location: Charleston, SC, USA
Distribution: Debian, Gentoo, Ubuntu, RHEL
Posts: 1,148
Blog Entries: 1

Rep: Reputation: 48
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.
 
Old 01-04-2007, 01:49 AM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Odd forum to ask this question, indeed, but here's one
possible solution.
Code:
awk -F"|" '{print $1"|"$4"|"$5}' datafile

Cheers,
Tink

Last edited by Tinkster; 01-04-2007 at 01:51 AM.
 
Old 01-04-2007, 09:53 AM   #4
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 13,597

Rep: Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080
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
 
  


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
file processing -- remove the first column of each line George2 Programming 7 11-19-2006 09:15 AM
Parsing rows and column data from a file using perl dav_y2k Programming 1 10-08-2006 11:57 AM
ripping a column from a text file dominant Linux - Newbie 1 01-31-2006 04:15 AM
How to delete a column in MySQL ? indian Linux - General 2 10-15-2004 01:02 PM
loading from text file using column width spyghost Programming 5 11-03-2003 01:34 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:51 AM.

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
Open Source Consulting | Domain Registration