LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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 04-12-2008, 04:58 AM   #1
jkeertir
Member
 
Registered: Mar 2008
Posts: 70

Rep: Reputation: 15
deleting a field using awk


Dear all,

Can anyone tell me how to delete one field using awk from the record.

Thanks in advance.

With Regards,
Keerti Jain
 
Old 04-12-2008, 05:08 AM   #2
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
You could simply print only the fields you want.
 
Old 04-12-2008, 07:56 AM   #3
froggy060768
LQ Newbie
 
Registered: Apr 2008
Location: Netherlands
Distribution: Centos 4.x & Fedora 9
Posts: 8

Rep: Reputation: 0
if you want to delete fields in fiels I recommend you to use SED otherwise. Just use AWK and you can pick the fields you want to print.

Comprehensive SED tutorial

http://www.grymoire.com/Unix/Sed.html

If you give me more information what you really like to do I can give you a better advice.
 
Old 04-12-2008, 01:53 PM   #4
prad77
Member
 
Registered: Mar 2008
Posts: 101

Rep: Reputation: 15
If you wanted to delete the 5th field from each line

>awk '{$5=""; print }' filename

Gentoo

Last edited by prad77; 04-17-2008 at 03:46 AM.
 
Old 04-13-2008, 12:12 PM   #5
froggy060768
LQ Newbie
 
Registered: Apr 2008
Location: Netherlands
Distribution: Centos 4.x & Fedora 9
Posts: 8

Rep: Reputation: 0
do you want it to write to a file?

Or only want to print everything except field 5?
 
Old 04-13-2008, 10:55 PM   #6
visitnag
Member
 
Registered: Mar 2008
Posts: 147

Rep: Reputation: 15
If you dont want second field (presuming space is the delimiter) of 5fields file just do at command prompt...

awk '{print $1,$3,$4,$5}' inputfl > outputfl
 
  


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 parameterize which field awk should print? dbland07666 Linux - Newbie 2 10-29-2007 03:49 PM
awk: how to find expression in a certain field? Micro420 Programming 5 08-08-2007 05:59 PM
Multiple Field Seperators in Awk... TheDarktrooper Programming 6 05-06-2004 04:50 AM
My field separator changes when using awk Helene Programming 3 05-01-2004 08:10 AM
Two field seperators in awk?? Astro Programming 2 11-09-2003 10:12 AM


All times are GMT -5. The time now is 05:21 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration