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
Replace text in parentheses lalelle Shell Programming and Scripting 5 02-20-2008 10:52 PM
Find and replace text PLEASE HELP bobo UNIX for Dummies Questions & Answers 6 01-12-2006 05:16 PM
Find and replace text bobo UNIX for Dummies Questions & Answers 1 01-12-2006 01:17 PM
Replace Text deep.singh UNIX for Dummies Questions & Answers 2 05-31-2005 12:03 PM
Replace Text with sed networkfre@k Shell Programming and Scripting 5 11-24-2004 05:52 PM

Closed Thread
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
  #1 (permalink)  
Old 05-10-2005
cdunavent cdunavent is offline
Registered User
  
 

Join Date: Sep 2001
Location: D.C.
Posts: 54
Need to replace text in an awk

Hey guys:

Running Solaris 5.5.1 and trying to write an easy /bin/sh script. Here is what I am doing...

grep "Total" /workspace_4/local/reports/cust_calls_5ess.050510 | awk '{print $4 "\t" $7 $8 $9 $10 $11 $12 $13 $14}'

It renders the following results...

315268 CLARKSONUNIVERSITYis:1485
516286 BROOKHAVENHOSPITALis:8372
516231 CITIBANKis:1247
978796 DMATSAYERis:3447
718239 NYSBRONXCHILDRENPSY.CTRis:778
508875 DMATSFRAM2is:5759
781378 DMATSLEXTN2is:20826
914285 CITYOFWHITEPLAINSis:5154

What I would like to do is replace the "is:" above with a <TAB>, so that it looks more like this...

315268 CLARKSONUNIVERSITY 1485
516286 BROOKHAVENHOSPITAL 8372
516231 CITIBANK 1247
978796 DMATSAYER 3447
718239 NYSBRONXCHILDRENPSY.CTR 778
508875 DMATSFRAM2 5759
781378 DMATSLEXTN2 20826
914285 CITYOFWHITEPLAINS 5154

The tricky part is that I have to print $7 thru $14 everytime so that I make sure to capture all of the info. I can't simply leave off $13 or $14, for example, because I might miss data dependin on how long the line is.

Any ideas???

-cd
  #2 (permalink)  
Old 05-10-2005
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
  
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
The simplest way would be to pipe your commands through sed....
Code:
grep blah | awk blah | sed 's/is/	/'
You can insert the tab literally, or use Ctrl-V Ctrl-I

Cheers
ZB
  #3 (permalink)  
Old 05-10-2005
cdunavent cdunavent is offline
Registered User
  
 

Join Date: Sep 2001
Location: D.C.
Posts: 54
Worked like a champ. THANKS!!

-cd
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 06:45 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