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 field in csv pcboss Linux 4 01-19-2008 06:24 PM
how to replace field for each record happyv Shell Programming and Scripting 12 06-26-2007 07:56 AM
Replace password field using ed/sed munch UNIX for Dummies Questions & Answers 6 04-30-2007 11:01 PM
find pattern and replace another field sergiioo Shell Programming and Scripting 3 04-11-2007 12:19 AM
Replace 10th Field by 2 PradeepRed Shell Programming and Scripting 2 01-19-2006 03:46 AM

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 04-21-2008
ajp7701 ajp7701 is offline VIP Member  
Supporter
  
 

Join Date: Dec 2007
Posts: 63
replace single field out of 60

I have a pipe delimited file with over 60 fields on each line, and hundreds of lines...I want to replace field 6 only....


So what is the better way to do this command....

awk -F'|' '{print $1"|"$2"|"$3"|"$4"|"$5"| TXT6"$7"|"$8"|"....$59"|"$60}' infile > outfile

I dont even know if this would work but its the first thing off the top of my head that could work...
  #2 (permalink)  
Old 04-21-2008
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
Code:
nawk -F'|' -v OFS='|' '$6="TXT6" $7' infile > outfile
  #3 (permalink)  
Old 04-21-2008
ajp7701 ajp7701 is offline VIP Member  
Supporter
  
 

Join Date: Dec 2007
Posts: 63
thx!! vgersh99

thank you thank you thank you vgersh99 that works perfect!
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 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