Appending two text files


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Appending two text files
# 1  
Old 04-21-2011
Appending two text files

Hi,

i am using unix server and bash shell..

i have two csv files...

i have file 1 as below...
Code:
arun
bvb
ssx
ccc

and file 2 as below
Code:
manas
friu
dfgg
cat

i need to get output as below format.
Code:
arun,manas
bvb,friu
ssx,dfgg
ccc,cat

i used cat file2>> file1 and cat file1
it displayed as below format
Code:
arun
bvb
ssx
ccc
manas
friu
dfgg
cat

please anyone help me to get the desired output format....Smilie

Moderator's Comments:
Mod Comment Please use [code] and [/code] tags when posting code, data or logs etc. to preserve formatting and enhance readability, thanks.

Last edited by zaxxon; 04-21-2011 at 04:02 AM.. Reason: code tags
# 2  
Old 04-21-2011
Code:
paste -d"," file1 file2

# 3  
Old 04-21-2011
I was going to suggest
Code:
paste file1 file2

But didnt know about -d option to introduce the commas
Cheers Franklin
# 4  
Old 04-25-2011
hi All,

Thanks for the code....

paste -d"," file1 file2 ... it works..

tan q...
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Appending a text to the top of each line

Platform : Oracle Linux 6.8 Shell : bash I have a file which has lines like below. These are SELECT queries (SQL) In each line, I want the word just after FROM keyword to be copied and printed on the top along with the word PROMPT. The words after FROM clause below are table names. So, they... (6 Replies)
Discussion started by: John K
6 Replies

2. Shell Programming and Scripting

Appending 2 text files - Problem in windows

Hello, I have text files to append and am able to do with cat. cat file1 file2 >file3 and file3 works fine in UNIX (checked with vi and it looks fine) but when i open the same file in windows I see 2nd file appended as a single-line. In other words, all the lines of 2nd file appended to... (2 Replies)
Discussion started by: magnus29
2 Replies

3. Shell Programming and Scripting

appending text to a file

I am trying to count number of record in a file and then append a trailer to that file. Trailer should e in the format as below T| <count of records> count of records ---> this count should be one less than the actual count obtained, as the file will have a header. I have drafted a... (3 Replies)
Discussion started by: siteregsam
3 Replies

4. UNIX for Dummies Questions & Answers

sed - appending text

Hey all I am trying to append a file called datebook.txt. I want to append the end of each line containing the name Fred with three ***. I believe I need to make the * loose its meta character meaning in addition to using the append command. I have tried several variations of this command and I... (3 Replies)
Discussion started by: citizencro
3 Replies

5. UNIX for Dummies Questions & Answers

appending in a single text file

actually, i have to grep the value of cpu usage from six differrent servers and it has to generated in a single report( in a single text or excel file). i have used the below command for grepping the value. top -n 1 > arun.txt cat arun.txt | grep 'init' | cut -c 49-53 > output1.csv like... (2 Replies)
Discussion started by: arunmanas
2 Replies

6. Shell Programming and Scripting

Appending text to a file

Hi, Want to append the text to a new file, echo "set `sqlplus -S abc/xyz123@localdb<<EOS" >> chk_test_append.sh echo "EOS`" >> chk_test_append.shbut getting the below error : what wrong is written ? With Regards (4 Replies)
Discussion started by: milink
4 Replies

7. UNIX for Dummies Questions & Answers

appending text on top of another file

Dear All, I have two files One is script file in which I am writing commands to append a text in a normal file. I want to insert the text on top of the file. I dont want to use sed and awk commands nor temp file. is it possible? (3 Replies)
Discussion started by: anjali
3 Replies

8. UNIX for Dummies Questions & Answers

Appending text to a number of similar filenames

Hi, I was wondering if there was a way to append something to filenames based on a wildcard. For example, if I have the following files in a directory: blah1 blah2 blah3 blah4 blah5 I want to rename these all to: blah1.txt blah2.txt blah3.txt blah4.txt blah5.txt Is there a... (4 Replies)
Discussion started by: Djaunl
4 Replies

9. Shell Programming and Scripting

Appending text of one file into other

hello, I am trying to append\insert the text that exists in file A into file B. for instance: File A contains: abcdef File B contains: ghijklm can i insert into file A the content in file B without damaging\deleting the input into file A? is there a command in shell that enables such... (1 Reply)
Discussion started by: danland
1 Replies
Login or Register to Ask a Question