append text from file1 to the end of each line in file2


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting append text from file1 to the end of each line in file2
# 1  
Old 12-01-2010
append text from file1 to the end of each line in file2

hi;

my file2.txt:
Code:
portname=1;list=10.11;l-
portname=2;list=10.12;l-
portname=3;list=10.13;l-
...

my file1.txt:
Code:
;"{'sector=%27'}"\&>

so; i want to see:
Code:
portname=1;list=10.11;l-;"{'sector=%27'}"\&>
portname=2;list=10.12;l-;"{'sector=%27'}"\&>
portname=3;list=10.13;l-;"{'sector=%27'}"\&>
...

how can i script it? Smilie
# 2  
Old 12-01-2010
Code:
awk 'NR==FNR{x=$0;next}{$0=$0""x}1' file1.txt file2.txt

This User Gave Thanks to bartus11 For This Post:
# 3  
Old 12-01-2010
Code:
perl -lne 'if (!$f){$n=$_; $f=1}else{$_.=$n; print}  ' file1.txt  file2.txt

This User Gave Thanks to k_manimuthu For This Post:
# 4  
Old 12-01-2010
thanks bartus11 Smilie
# 5  
Old 12-01-2010
Code:
awk 'NR==1{a=$0;next} {print $0 a}' file1.txt file2.txt

This User Gave Thanks to rdcwayx For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Copy(append ) the contents of file1 and file2 to file3

Platform : Oracle linux 6.5 I have two log files with the following contents # ls -l total 8 -rw-r--r--. 1 root root 75 Dec 10 20:55 myLogfile1.log -rw-r--r--. 1 root root 51 Dec 10 20:57 myLogfile2.log # # cat myLogfile1.log hello world jaded zombies acted quaintly but kept driving... (9 Replies)
Discussion started by: kraljic
9 Replies

2. Shell Programming and Scripting

How to append two files(file1 and file2) Please help me?

Hi I have two files file1 and file2 File1 10,000 entries:It has 3 columns below. conn=232257 client=xxx.xxx.xx.xxx:60491 protocol=LDAP File2 has 500 entries It has two columns. conn=232257 dn="uid=xxxx,ou=xxxx,ou=xxxx,dc=xxxxx,dc=xxxx" conn=232398... (10 Replies)
Discussion started by: buzzme
10 Replies

3. Shell Programming and Scripting

look for line from FILE1 at FILE2

Hi guys! I'm trying to write something to find each line of file1 into file2, if line is found return YES, if not found return NO. The result can be written to a new file. Can you please help me out? FILE1 INPUT: WATER CAR SNAKE (in reality this file has about 600 lines each with a... (2 Replies)
Discussion started by: demmel
2 Replies

4. UNIX for Dummies Questions & Answers

if matching strings in file1 and file2, add column from file1 to file2

I have very limited coding skills but I'm wondering if someone could help me with this. There are many threads about matching strings in two files, but I have no idea how to add a column from one file to another based on a matching string. I'm looking to match column1 in file1 to the number... (3 Replies)
Discussion started by: pathunkathunk
3 Replies

5. Shell Programming and Scripting

find a certain line and append text to the end of the line

After I create printer queues in AIX, I have to append a filter file location within that printers custom file. within lets say test_queue.txt I need to find the row that starts with :699 and then I need to append on the end the string /usr/local/bin/k_portrait.sh. Now I've gotten the sed... (2 Replies)
Discussion started by: peachclift
2 Replies

6. Shell Programming and Scripting

Append text to end of every line

I've scoured the internet with mixed results. As an amateur I turn to the great minds here. I have a text file of 80 or so lines. I want to add ".pdf" to the end of each line. (For now that's it) Most of the internet points toward using "sed". I don't know coding but can figure things out... (4 Replies)
Discussion started by: spacebase
4 Replies

7. Shell Programming and Scripting

Append text to end of line on all lines

Hi, I've spent some time researching for this but can't seem to find a solution. I have a file like this 1234|Test|20101111|18:00|19:00There will be multiple lines in the file with the same kind of format. For every line I need to make it this 1234|Test|20101111|18:00|19:00||create... (5 Replies)
Discussion started by: giles.cardew
5 Replies

8. Shell Programming and Scripting

replacing text in file1 with list from file2

I am trying to automate a process of searching through a set of files and replace all occurrences of a formatted text with the next item in the list of a second file. Basically i need to replace all instances of T????CLK???? with an IP address from a list in a second file. the second file is one IP... (9 Replies)
Discussion started by: dovetail
9 Replies

9. Shell Programming and Scripting

Append text at end of the first line in a file

Hi I need to append some text @ end of the first line in a file. like myfile.txt list = a,b,c list.a=some.. I give the arg "d" . now it append at end of first line list=a,b,c,d list.a=some... Please help me out this (7 Replies)
Discussion started by: catgovind
7 Replies

10. UNIX for Dummies Questions & Answers

using sed to append text to the end of each line

Anyone know how to use SED to append a comma to the end of each line example: field1,field2,field3,field4 If i Cat /textfile ---- How can i append the end of /textfile with a comman? (8 Replies)
Discussion started by: Redg
8 Replies
Login or Register to Ask a Question