The UNIX and Linux Forums  

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
Processing a CSV file janemary.a High Level Programming 1 05-11-2007 07:27 AM
Have a shell script check for a file to exist before processing another file heprox Shell Programming and Scripting 3 11-14-2006 03:26 AM
File processing on perl garric Shell Programming and Scripting 2 09-02-2006 12:25 AM
processing line in file fablef00 Shell Programming and Scripting 8 01-23-2006 11:41 AM
Processing a text file TheCrunge UNIX for Dummies Questions & Answers 1 11-09-2005 11:47 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 10-04-2007
manouche manouche is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 13
processing a file with sed and awk

Hello,

I have what is probably a simple task in text manipulation, but I just can't wrap my brain around it.

I have a text file that looks something like the following. Note that some have middle initials in the first field and some don't.

john.r.smith:john.smith@yahoo.com
george.w.bush:gwbush@whitehouse.gov
larry.doby:ldoby@hotmail.com
tom.t.hall:tom.t.hall@nashville.com


I want to end up with a file that looks something like this:


john<tab>smith<tab>john.smith@yahoo.com
george<tab>bush<tab>gwbush@whitehouse.gov
larry<tab>doby<tab>ldoby@hotmail.com
tom<tab>hall<tab>tom.t.hall@nashville.com

So, I want to split each line into two fields separated by a tab. I was able to easily do this with awk and wrote it to file.

awk -F':' '{print $1"\t"$2}' inputfile > outputfile

I want to eliminate the middle initial in field 1, if present. I can do that with sed, but how can I process only field 1 and leave field 2 intact?

Your suggestions are most welcome.
 

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 10:42 PM.


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