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
replace the column values. charandevu Shell Programming and Scripting 6 04-02-2008 03:21 AM
How to check Null values in a file column by column if columns are Not NULLs Mandab Shell Programming and Scripting 7 03-15-2008 09:57 AM
Convert Header into Column in Text file vsubbu1000 Shell Programming and Scripting 7 08-06-2007 05:09 AM
replace a column values with the first value in column sumeet UNIX for Advanced & Expert Users 3 02-06-2007 01:13 PM
Replace 10th column with a new column--- Terriblly hurry ahmedwaseem2000 Shell Programming and Scripting 2 09-06-2005 02:10 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 06-17-2008
jkl_jkl jkl_jkl is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 46
awk/sed column replace using column header - help


Code:
$ cat log.txt
Name Age Sex Lcation nfld alias xsd
CC 25 M XYZ asx KK Y
BB 21 F XAS awe SS N
SD 21 M AQW rty SD A

How can I replace the column with header "Lcation" with the column with header "alias" and delete the "alias" column?

so that the final output will become:


Code:
Name Age Sex alias nfld xsd
CC 25 M KK asx Y
BB 21 F SS awe N
SD 21 M SD rty A

I can do this by specifying the "field number"(like below), but I wanted to do that using "field header name"

Code:
$ awk  '$4=$6' log.txt  | awk '{$6=""}1'

Please help.
 

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 07:54 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