Need to replace a column value in UNIX file


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Old 12-01-2014
Need to replace a column value in UNIX file

Hi All,

I am having a file like below
Code:
01098546       3  56120610010377101008311121 001382    71    003         5011339
01099413       1  42120500010247081106112121 000304    46    002         2011339

I want to replace the 78 column from 3 to 4 and I need the file as below
Code:
01098546       3  56120610010377101008311121 001382    71    003         5011439
01099413       1  42120500010247081106112121 000304    46    002         2011439


Can you please help me in getting this done

Thanks,
Arun

---------- Post updated at 04:36 PM ---------- Previous update was at 04:25 PM ----------

Got my answer used the below command to make it done

Code:
 sed -i 's/339$/439/' file


Last edited by Franklin52; 12-01-2014 at 07:08 AM.. Reason: adding code tags
# 2  
Old 12-01-2014
If these are constant 80 character width records:
Code:
sed -e 's/3\(..\)$/4\1/'

If not:
Code:
awk 'BEGIN { FS = OFS = ""; } $(78) == "3" { $(78) = "4"; } { print; }'

Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Use awk to replace numbers in a file with a column from another file nastaziales Shell Programming and Scripting 8 07-06-2018 11:04 AM
Replace first column in 17GB File fedora132010 Shell Programming and Scripting 7 12-21-2015 01:31 PM
Match column 8 in file 1 with column 2 in file 2 and replace.. kieranfoley Shell Programming and Scripting 5 11-19-2015 01:36 PM
Replace column values from other file samaritan Shell Programming and Scripting 8 07-30-2014 02:12 PM
Replace a character of specified column(s) of all rows in a file njny Shell Programming and Scripting 8 12-16-2013 09:55 PM
To replace the value of the column in a fixed width file ginrkf Shell Programming and Scripting 14 08-04-2013 12:38 PM
Copy a column to another column in UNIX fixedwidth file kiranparsha UNIX for Advanced & Expert Users 4 12-21-2012 06:15 AM
Replace 2nd column in file sdosanjh Shell Programming and Scripting 14 12-18-2012 03:05 AM
Replace column that matches specific pattern, with column data from another file prashali Shell Programming and Scripting 7 05-15-2012 04:17 PM
replace a column with values from another file chen.xiao.po UNIX for Dummies Questions & Answers 11 07-04-2011 06:10 AM
Replace column with column from another file doobe01 Shell Programming and Scripting 11 04-13-2011 06:29 PM
Replace values in a specified column of a file Gussifinknottle UNIX for Dummies Questions & Answers 4 02-13-2011 09:14 AM
Match column 3 in file1 to column 1 in file 2 and replace with column 2 from file2 rydz00 Shell Programming and Scripting 7 11-09-2010 10:28 AM
Replace string in unix from 10th column onwards rpk2008 UNIX and Linux Applications 3 11-19-2009 11:42 PM
replace a column in a file if it matches certain pattern Krrishv Shell Programming and Scripting 6 03-12-2009 05:16 AM