If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > using awk

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-06-06, 15:16
saccskiz saccskiz is offline
Registered User
 
Join Date: Feb 2004
Posts: 143
using awk

I have a flat file file1.txt with fixed length fields. It is like this :

100<>JOHN <>ERERXC<>4343<>YMC
200<>MARK <>BNDF <>3434<>BNU
300<>SCOTT <>TRTRR <>4343<>JNI
400<>BENJAMIN <>VZDSS <>3434<>IJM

I want to remove the whole of the 3rd column above. In other words. my output needs
to be as below in another file called file2.txt

100<>JOHN <>4343<>YMC
200<>MARK <>3434<>BNU
300<>SCOTT <>4343<>JNI
400<>BENJAMIN <>3434<>IJM

How do I do this using awk ? Or is there another method ? Thanks
Reply With Quote
  #2 (permalink)  
Old 03-06-06, 17:04
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,456
Cool


Use substr:
Code:
awk 'print substr($0,1,30) substr($0,41);}' file1.txt >file1.new

__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
  #3 (permalink)  
Old 03-06-06, 17:56
hyperbole hyperbole is offline
Registered User
 
Join Date: Jan 2006
Posts: 32
Code:
awk 'BEGIN { FS = "<>"; OFS = "<>" }; {print $1, $2, $4}' file1.txt


.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On