how to combine 2 files using sed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to combine 2 files using sed
# 1  
Old 08-07-2010
how to combine 2 files using sed

hi all
I have two files
file1
aaa
bbb
ccc
ddd

file2
111
222
333
444

I would like to using "SED" combine two files together
Please help

Thank all
# 2  
Old 08-07-2010
Bug

hi yuesko,

why use SED? many ways to do what you want...this for example:
cat one.txt >> three.txt|cat two.txt >> three.txt|cat three.txt

cheers!
# 3  
Old 08-07-2010
Hi.

How would you like to "combine" them (what should the new file look like)?

Depending, cat, paste, awk, etc. could be better choices of command.

To concatenate them, why use:
Code:
$ sed !d file2 >> file1
$ cat file1
aaa
bbb
ccc
ddd
111
222
333
444

when
Code:
cat file2 >> file1

would do.
# 4  
Old 08-08-2010
Code:
sed -n 'p' file1 file2 > file3

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

awk with sed to combine lines and remove specific odd # pattern from line

In the awk piped to sed below I am trying to format file by removing the odd xxxx_digits and whitespace after, then move the even xxxx_digit to the line above it and add a space between them. There may be multiple lines in file but they are in the same format. The Filename_ID line is the last line... (4 Replies)
Discussion started by: cmccabe
4 Replies

2. UNIX for Beginners Questions & Answers

Automate splitting of files , scp files as each split completes and combine files on target server

i use the split command to split a one terabyte backup file into 10 chunks of 100 GB each. The files are split one after the other. While the files is being split, I will like to scp the files one after the other as soon as the previous one completes, from server A to Server B. Then on server B ,... (2 Replies)
Discussion started by: malaika
2 Replies

3. UNIX for Dummies Questions & Answers

Combine files

i have 3 files: file1, file2 and file3 file1 has this content: #!/bin/ksh sqlplus username/password@Servername << EOF file2 has this content: drop table dropme cascade constraints; file3 has this content: EOF all said and done, file1, file2 and file2 will look like... (1 Reply)
Discussion started by: lawsongeek
1 Replies

4. UNIX for Dummies Questions & Answers

Combine multiple sed

Would like to convert it to one line sed -i -e '/./,$!d' term1.txt sed -i '2d' term1.txt sed -i '/^$/Q' term1.txt cat term1.txt>> test1.txt Appreciate if someone could point out the error sed -i -e '/./,$!d' -e '2d' -e '/^$/Q' term1.txt cat term1.txt>> $test1.txt ... (6 Replies)
Discussion started by: w020637
6 Replies

5. Shell Programming and Scripting

Combine sed command

Hi I have command and i want to short it. tr -c '' '' | sed 's/---/-/g' I want one sed command it is possible to include tr command in to sed Thanks (8 Replies)
Discussion started by: asavaliya
8 Replies

6. Shell Programming and Scripting

combine multiple files by column into one files already sorted!

I have multiple files; each file contains a certain data in a column view simply i want to combine all those files into one file in columns example file1: a b c d file 2: 1 2 3 4 file 3: G (4 Replies)
Discussion started by: ahmedamro
4 Replies

7. UNIX for Dummies Questions & Answers

What is the command use to combine line using sed

Hi all, What is the sed command use to combine line? Example: Below is an output after extracted from few commands aaa bbb ccc ddd eee fff ggg and i would like to combine all the line as shown below, aaa,bbb,ccc,ddd,eee,fff (5 Replies)
Discussion started by: 793589
5 Replies

8. Shell Programming and Scripting

sed, grep, cut or combine?

I am a beginner at shell scripting, actually i am working on my first script right now. Anyway i have searched the world how to grep two letters from each word (it will always just be two words). For example: Example Blablabla I want my script to cut out Ex (from the first word) and Bl... (4 Replies)
Discussion started by: maskot
4 Replies

9. UNIX for Dummies Questions & Answers

SImple HELP! how to combine two lines together using sed or awk..

hi..im new to UNIX... ok i have this information in the normal shell... there are 2 lines display like this: h@hotmail.com k@hotmail.com i want it to display like this with a space betweem them h@hotmail.com k@hotmail.com the information is stored in a text file.... anyone... (10 Replies)
Discussion started by: forevercalz
10 Replies

10. UNIX for Dummies Questions & Answers

sed or grep or perl combine two lines

how do i search for the phrase "expected" on line one and "received" on line two. (there is a newline in between the two) I would like to know if/how this can be done in perl and/or grep and/or sed (3 Replies)
Discussion started by: artjaniger
3 Replies
Login or Register to Ask a Question