How to change values in certain column only in every line (any script)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to change values in certain column only in every line (any script)
# 1  
Old 05-17-2010
How to change values in certain column only in every line (any script)

Let say in a file I have lines of data like this :

13;2073;461496;15075341;3;001f7d3a;2042063674;
13;2074;461446;15080241;6;001ed33a;2042020154;
13;2075;461401;15085270;6;001f593b;2042054459;
13;2076;461381;15087160;6;001f7483;2042061443;
13;2077;461419;15083419;6;001eca1a;2042017818;

I want to change the values in the 6th column in every line (001f7d3a, 001ed33a, 001f593b, 001f7483 and 001eca1a) to different values.

Can anybody give me any script (unix or perl) to perform this task? Your help is very much appreciated.. cuz I can't afford to change the values in column 6 manually, there are thousands of lines actually Smilie! THANKS
# 2  
Old 05-17-2010
what new values do you want....

(awk is most likely your friend here...)
# 3  
Old 05-17-2010
new values would be:
A1000001EFFFF1
A1000002000000
A1000002100000
A1000002200000
A1000002300000
# 4  
Old 05-17-2010
Assuming you have the new values in file2:
Code:
awk -F";" '{getline $6 < "file2"}1' OFS=";" file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk script to append suffix to column when column has duplicated values

Please help me to get required output for both scenario 1 and scenario 2 and need separate code for both scenario 1 and scenario 2 Scenario 1 i need to do below changes only when column1 is CR and column3 has duplicates rows/values. This inputfile can contain 100 of this duplicated rows of... (1 Reply)
Discussion started by: as7951
1 Replies

2. Shell Programming and Scripting

Bring values in the second column into single line (comma sep) for uniq value in the first column

I want to bring values in the second column into single line for uniq value in the first column. My input jvm01, Web 2.0 Feature Pack Library jvm01, IBM WebSphere JAX-RS jvm01, Custom01 Shared Library jvm02, Web 2.0 Feature Pack Library jvm02, IBM WebSphere JAX-RS jvm03, Web 2.0 Feature... (10 Replies)
Discussion started by: kchinnam
10 Replies

3. Shell Programming and Scripting

Extracting values based on line-column numbers from multiple text files

Dear All, I have to solve the following problems with multiple tab-separated text file but I don't know how. Any help would be greatly appreciated. I have access to Linux mint (but not as a professional). I have multiple tab-delimited files with the following structure: file1: 1 44 2 ... (5 Replies)
Discussion started by: Bastami
5 Replies

4. Shell Programming and Scripting

Change values in .conf file with a script

This is my first time posting here...so be gentle. Suppose I have a test.conf file that contains a value such as a IP. I would like to be able to use the Dialog Utility in Linux to allow me to enter the new IP in a Dialog form...and the results get saved into the test.conf file in the place... (4 Replies)
Discussion started by: calahanp
4 Replies

5. Shell Programming and Scripting

Read column values from previous and next line using awk

Hi, I have a csv file which contains data that looks something like this: Key1 Key2 Key3 New_Key1 New_Key2 New_Key3 102 30 0 - - - 102 40 1 30 40 50 102 50 2 40 50 ... (4 Replies)
Discussion started by: Nishi_Licious
4 Replies

6. UNIX for Dummies Questions & Answers

Command line / script option to filter a data set by values of one column

Hi all! I have a data set in this tab separated format : Label, Value1, Value2 An instance is "data.txt" : 0 1 1 -1 2 3 0 2 2 I would like to parse this data set and generate two files, one that has only data with the label 0 and the other with label -1, so my outputs should be, for... (1 Reply)
Discussion started by: gnat01
1 Replies

7. Shell Programming and Scripting

Change file content 4 column to one Column using script

Hi Gurus, I have file content sample: ,5113955056,,TAgent-Suspend ,5119418233,,TAgent-Suspend ,5102119078,,TAgent-Suspend filenames 120229H5_suspend, 120229H6_unsuspend I receive those files one of directory /home/temp/ I need following: 1. Backup first /home/temp/ file to... (5 Replies)
Discussion started by: thepurple
5 Replies

8. Shell Programming and Scripting

Change values in Log4j.xml using ksh script

Hi, I am new to UNIX and shell scripting. I have to create a shell script(ksh) which parses log4j.xml file for a given webservice name and change the corresponding value from INFO to DEBUG or vice-versa. My log4j.xml looks like:- <!-- Appender WEBSERVICENAME--> <appender... (3 Replies)
Discussion started by: sanjeevcseng
3 Replies

9. Shell Programming and Scripting

Perl script to change values in datafiles

Hi all, Let say I have 2 files, 1 is source file and another is destination file. Source file contains the following : Kitten Dogs Donkey Chicken Turkey And destination file contains : Kitten, 0 Dogs, 0 Donkey, 0 Chicken, 0 Turkey, 0 Kitten, 0 Dogs, 0 Donkey, 0 (16 Replies)
Discussion started by: luna_soleil
16 Replies

10. Shell Programming and Scripting

print unique values of a column and sum up the corresponding values in next column

Hi All, I have a file which is having 3 columns as (string string integer) a b 1 x y 2 p k 5 y y 4 ..... ..... Question: I want get the unique value of column 2 in a sorted way(on column 2) and the sum of the 3rd column of the corresponding rows. e.g the above file should return the... (6 Replies)
Discussion started by: amigarus
6 Replies
Login or Register to Ask a Question