[solved] merging two files and writing to another file- solved

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [solved] merging two files and writing to another file- solved
# 1  
Old 10-07-2010
[solved] merging two files and writing to another file- solved

i have two files as



and the output should be:



and i am using the below script which is not working sometimes:
rm $file3
while  read line1
line2=`cat $file2 | sed -n "${i},${i}p" `
echo "${line1}~${line2}" >> $file3
done <$file1

correct me on this

---------- Post updated at 02:37 PM ---------- Previous update was at 02:12 PM ----------

issue resolved now. it is working fine.

i am transferring the file in wrong mode

Last edited by Scott; 10-07-2010 at 08:00 PM.. Reason: Please use code tags
# 2  
Old 10-07-2010
What about paste Smilie
paste -d= file2 file1

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Solved] awk compare two different columns of two files and print all from both file

Hi, I want to compare two columns from file1 with another two column of file2 and print matched and unmatched column like this File1 1 rs1 abc 3 rs4 xyz 1 rs3 stu File2 1 kkk rs1 AA 10 1 aaa rs2 DD 20 1 ccc ... (2 Replies)
Discussion started by: justinjj
2 Replies

2. Shell Programming and Scripting

[Solved] Writing output to the console

Hi All, I have written one script in which am writting the result to the log file. I want to display the results on the console also if ; then echo "$result doesnot match with the host file">>InputHostsFileErrors.txt else echo "$result input matches with the host... (7 Replies)
Discussion started by: sharsour
7 Replies

3. Programming

[Solved] Cannot execute file that include files

Iam trying to execute a file that include many files but it seems my main copy.c can't read anyone of them ----------------------------------------------------------------------------------------- Copy.c #include <sys/stat.h> #include <fcntl.h> #include "tlpi_hdr.h" #ifndef BUF_SIZE /*... (2 Replies)
Discussion started by: fwrlfo
2 Replies

4. UNIX for Dummies Questions & Answers

[Solved] Writing a loop to changing the names of files in a directory

Hi, I would like to write a loop to change the names of files in a directory. The files are called data1.txt through data1000.txt. I'd like to change their names to a1.txt through a1000.txt. How do I go about doing that? Thanks! (2 Replies)
Discussion started by: evelibertine
2 Replies

5. Shell Programming and Scripting

[solved]compare two files

I have to files. One file contains two fields: server|userThe other files contains records with 13 fields (always 13). The fields to match on are 3 and 5, but I want to output the whole record. I have been trying this over and over with not much success, or at least inaccurate success. Here is my... (0 Replies)
Discussion started by: dagamier
0 Replies

6. Shell Programming and Scripting

The -f switch is not identifying files[solved]

(1 Reply)
Discussion started by: lowExpectations
1 Replies

7. UNIX for Dummies Questions & Answers

[Solved] take name of directory and files as variables

hi, want to create script that takes name of directory and all files and will copy each file to new directory. then fix errors like files do not exist or no permission to create new directory... these what I have so far... #!/bin/sh dir=~/Documents/Scripts/Copy for i in $(pwd) $(ls)... (23 Replies)
Discussion started by: me.
23 Replies

8. Shell Programming and Scripting

[Solved] combine two files

All, I have two files. each file contain same number of lines. means if file 1 contain 10 line then file 2 also contain 10 line. 1. scp userid@server:/tmp/a1.txt scp userid@server:/tmp/a2.txt scp userid@server:/var/adm/a3.txt 2. /tmp/ /tmp/ /var/adm/ Now I want my O/P as... (2 Replies)
Discussion started by: anshu ranjan
2 Replies

9. Shell Programming and Scripting

write to multiple files depending on file type (solved)

I want a script that will add comments to a file before check-in files. comments depend on type of files. i have a script to list files in the directory that will be checked-in There are xml, js, html, vm files. vm will use comments like c/c++ ( // or /*..*/) can you help me add a comment line... (0 Replies)
Discussion started by: pradeepmacha
0 Replies

10. HP-UX

[Solved] Deleting a all core files present in file systems ?

Hi All IN HPUX 11 How to delete an unwanted "core" file with a single command which is being generated in different locations of the system the command should be able to free up the space occupied by all "core" file which is present in different folders and filesytems in a system ... (5 Replies)
Discussion started by: sidharthmellam
5 Replies
Login or Register to Ask a Question

Featured Tech Videos