Changing and swapping the Values in the files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Changing and swapping the Values in the files
# 1  
Old 11-03-2011
Changing and swapping the Values in the files

Hi all
we have a file ONE like this
Code:
12345  98765
67222  74252
76991  90091

and we have one more file TWO like
Code:
huiiii 67jjjj u988 99999 uj99j 98765
hujg 7yhh ij999 78688 ijo99 74252

Now i want create THREE file which
is like
Code:
huiiii 67jjjj u988 12345 uj99j 98765
hujg 7yhh ij999 67222 ijo99 74252

Please help this it is very urgent
# 2  
Old 11-03-2011
Everyone at the UNIX and Linux Forums gives their best effort to reply to all questions in a timely manner. For this reason, posting questions with subjects like "Urgent!" or "Emergency" and demanding a fast reply are not permitted in the regular forums.

For members who want a higher visibility to their questions, we suggest you post in the Emergency UNIX and Linux Support Forum. This forum is given a higher priority than our regular forums.

Posting a new question in the Emergency UNIX and Linux Support Forum requires forum Bits. We monitor this forum to help people with emergencies, but we do not not guarantee response time or best answers. However, we will treat your post with a higher priority and give our best efforts to help you.

If you have posted a question in the regular forum with a subject "Urgent" "Emergency" or similar idea, we will, more-than-likely, close your thread and post this reply, redirecting you to the proper forum.

Of course, you can always post a descriptive subject text, remove words like "Urgent" etc. (from your subject and post) and post in the regular forums at any time.


Thank you.

The UNIX and Linux Forums
# 3  
Old 11-03-2011
Code:
nawk 'FNR==NR{f1[$2]=$1;next} $NF in f1 {$(NF-2)=f1[$NF]}1' ONE TWO > THREE

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Changing CSV files with date . Subtracting date by values

Hi All, I have a CSV file which is as below. Basically I need to take the year column in it and find if the year is >= 20152 . If that is then I should subtract all values by 6. In the below example in description I am having number mentioned as YYWW so I need to subtract those by -5. Whereever... (8 Replies)
Discussion started by: arunkumar_mca
8 Replies

2. UNIX for Beginners Questions & Answers

Swapping content b/n two files

I am having two files file1&file2.i just want to swap the selected contents btwn two files #file1 content: Title:xxxx Hello Imran #file2 content: Title:YYYY Hello Meeran i just want only second line in both files should be swapped.The title should remain in the same file. i just... (5 Replies)
Discussion started by: Meeran Rizvi
5 Replies

3. Shell Programming and Scripting

Changing values in the first column.

I have a file which looks like this: 1 3 5 5 3 2 1 5 3 6 3 2 0 5 6 3 2 9 0 4 5 6 4 9 In the first column, instead of 1, I want to place +1 and instead of 0, I want -1 to be put. So the generated file should look like this: +1 3 5 5 3 2 +1 5 3 6 3 2 -1 5 6 3 2 9 -1 4 5 6 4 9 Just to... (9 Replies)
Discussion started by: shoaibjameel123
9 Replies

4. Shell Programming and Scripting

Swapping a string of numbers between higher and lower order values(HEX)

I have this below string in a variable cutString=21222222222222222122222222222222 this string is nothing but hex values depicted as below 21:22:22:22:22:22:22:22:21:22:22:22:22:22:22:22 so what i want to achieve is swap the lower order with higher order values in the... (3 Replies)
Discussion started by: vivek d r
3 Replies

5. UNIX for Dummies Questions & Answers

Changing the values of a column using awk and gsub

Hi, I am using the following code to change NA to X in only the 5th column of my text file: awk '{gsub("NA","x",$5)}1' in.file > out.file How can I modify this code if I want to change NA to X in multiple columns of the text file (i.e. columns 5,6 and 7). Thanks! (2 Replies)
Discussion started by: evelibertine
2 Replies

6. UNIX for Dummies Questions & Answers

Changing values of a column based on formula

Hi, I have a tab delimited text file with two columns where the second column takes on values between 1 and 6 (including). If the value of the second column, includes 1,2,3 I want to replace it with LOW. If it is 4,5,6 I want to replace it with HIGH. How do I go about doing that? Thanks ... (3 Replies)
Discussion started by: evelibertine
3 Replies

7. Shell Programming and Scripting

swapping the values of variable!

Hi All, newbie here, i'm just wondering how can i swap the two values of variables without using the third variable. Please advise, Thanks, (5 Replies)
Discussion started by: nikki1200
5 Replies

8. Shell Programming and Scripting

sed/awk changing values

Can somebody help me out and provide me with a SED or AWK solution that converts TO_DATE CLAUSE -> TIMESTAMP I need to keep the PARTION value (HISTORY_20110417) and DATE/TIME value (2011-04-18 00:00:00) the same for every line PARTITION HISTORY_20110417 VALUES LESS THAN (TO_DATE('... (3 Replies)
Discussion started by: BeefStu
3 Replies

9. Shell Programming and Scripting

Changing values with increasing numbers!

Hi all, i have a command named "vmchange" and i must use it for thousands of data which must be changed. For example, vmchange -m N0001 vmchange -m N0002 vmchange -m N0003 ... ... vmchange -m N0100 How can i do that in awk or bash script? Any help would be greatly appreciated.. ... (5 Replies)
Discussion started by: oduth
5 Replies

10. UNIX for Dummies Questions & Answers

Changing Values in the Kernel

I'm getting fork failed errors. I was told I needed to upgrade my swap space but also need to change some values for some parameters in the kernel and add 2 new parameters. I not sure of the correct way of doing this. Thanks in Advance (4 Replies)
Discussion started by: dman110168
4 Replies
Login or Register to Ask a Question