Need to replace a column value in UNIX file


 
Thread Tools Search this Thread
Homework and Emergencies Emergency UNIX and Linux Support Need to replace a column value in UNIX file
# 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 08: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 Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace first column in 17GB File

Hi All, I have a 17GB file and i want to set the first column from 1234567890 to just 0, how can i do it using sed command? thanks, ---------- Post updated at 03:09 PM ---------- Previous update was at 03:07 PM ---------- btw, my file is delimited by "|" and 1234567890 is just an... (7 Replies)
Discussion started by: fedora132010
7 Replies

2. Shell Programming and Scripting

Match column 8 in file 1 with column 2 in file 2 and replace..

I am looking at the NR==FNR posts and trying to use them to achieve the following but I am not getting it. I have 2 files. I want to match column 8 in file 1 with column 2 in file 2. When they match I want to replace column 9 in file 1 with column 1 in file 2. This is and extract from file 1 ... (5 Replies)
Discussion started by: kieranfoley
5 Replies

3. Shell Programming and Scripting

Replace column values from other file

I have one file as it has the following format File1 S No Site IP Address 1 Australia 192.168.0.1/26 2 Australia 192.168.0.2/26 3 Australia 192.168.0.3/26 I need awk/sed command to replace the column2 value ( under Site) with some other... (8 Replies)
Discussion started by: samaritan
8 Replies

4. UNIX for Advanced & Expert Users

Copy a column to another column in UNIX fixedwidth file

Hi All, I have a fixedwidth file of length 3000. Now i want to copy a column of 4 chars i.e( length 1678-1681) to column 1127 – 1171 to the same file. Please let me know how can i achive using a single command in fixed width file. Also source column length is 4 chars and target column length... (4 Replies)
Discussion started by: kiranparsha
4 Replies

5. Shell Programming and Scripting

Replace column that matches specific pattern, with column data from another file

Can anyone please help with this? I have 2 files as given below. If 2nd column of file1 has pattern foo1@a, find the matching 1st column in file2 & replace 2nd column of file1 with file2's value. file1 abc_1 foo1@a .... abc_1 soo2@a ... def_2 soo2@a .... def_2 foo1@a ........ (7 Replies)
Discussion started by: prashali
7 Replies

6. UNIX for Dummies Questions & Answers

replace a column with values from another file

Dear all, I have a file1.pdb in pdb format and a dat file2 containing values, corresponding to the atoms in the pdb file. these values (file2.dat) need to be in the column instead of the 0.00 (file1) values for each atom in file1.pdb .(the red values must be replaced by the blue ones,in order)... (11 Replies)
Discussion started by: chen.xiao.po
11 Replies

7. Shell Programming and Scripting

Replace column with column from another file

Hello, I am trying to replace the column in file1 with the column from file2. The two files will have the same amount of rows. Each row will correspond with the same row in the other file. File1 "Replace this column" 500 13-APR-2011... (11 Replies)
Discussion started by: doobe01
11 Replies

8. UNIX for Dummies Questions & Answers

Replace values in a specified column of a file

Hello, I have a file with four columns and I would like to replace values in the second column only. An arbitrary example is: 100 A 105 B 200 B 205 C 300 C 305 D 400 D 405 E 500 E 505 F I need to replace the second column as shown below: ... (4 Replies)
Discussion started by: Gussifinknottle
4 Replies

9. Shell Programming and Scripting

Match column 3 in file1 to column 1 in file 2 and replace with column 2 from file2

Match column 3 in file1 to column 1 in file 2 and replace with column 2 from file2 file 1 sample SNDK 80004C101 AT XLNX 983919101 BB NETL 64118B100 BS AMD 007903107 CC KLAC 482480100 DC TER 880770102 KATS ATHR 04743P108 KATS... (7 Replies)
Discussion started by: rydz00
7 Replies

10. UNIX and Linux Applications

Replace string in unix from 10th column onwards

Hi All, I need to replace the last 19 bytes of the following string My_Org_Testing_20090102_231124.txt (Text_Date_Time.txt). I would like to derive the current time using "date +%Y%m%d_%H%M%S.txt" and replace the last 19 bytes of the above string I would appreciate if someone could... (3 Replies)
Discussion started by: rpk2008
3 Replies
Login or Register to Ask a Question