The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Traverse a flatfile and check for errors aravindc Shell Programming and Scripting 1 04-17-2008 02:56 AM
Adding field of flatfile by an index. djsal Shell Programming and Scripting 2 02-14-2007 12:53 PM
How to insert a record in fixed width flatfile limou Shell Programming and Scripting 1 03-13-2006 04:55 PM
encrypting Unix flatfile rkumar28 UNIX for Dummies Questions & Answers 1 04-29-2004 09:31 AM
Finding a column in a flatfile peter.herlihy UNIX for Dummies Questions & Answers 3 01-07-2002 08:08 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-06-2008
rsprabha rsprabha is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 3
Deleting column from a flatfile with delimiter

I have a set of flatfiles which have columns delimited by #. How can a particular column be deleted in all the flatfiles. All flatfiles have same number of columns.
  #2 (permalink)  
Old 06-07-2008
jaduks's Avatar
jaduks jaduks is offline
Registered User
  
 

Join Date: Aug 2007
Location: Assam,India
Posts: 166
Code:
$ cat filea
a#b#c
d#e#f
g#h#i

if you have to delete the 2nd column,

$ awk 'BEGIN{FS=OFS="#"}{$2=""}{print}' filea
a##c
d##f
g##i

or 

$ awk 'BEGIN{FS=OFS="#"}{$2="";gsub(FS "+",FS)}1' filea
a#c
d#f
g#i
//Jadu
  #3 (permalink)  
Old 10-03-2008
rsprabha rsprabha is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 3
Hi,
Thanks for the reply. Can you please clarify one point. What is "1' at the end of the braces mean.
  #4 (permalink)  
Old 10-03-2008
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,944
Quote:
Originally Posted by rsprabha View Post
Hi,
Thanks for the reply. Can you please clarify one point. What is "1' at the end of the braces mean.
1 => print
  #5 (permalink)  
Old 10-03-2008
rsprabha rsprabha is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 3
Thanks a lot once again.
  #6 (permalink)  
Old 10-03-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Or cut -d '#' -f1,3- file
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:12 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0