shell scripting.. where to start?
never written a script before, but now im finding the need for them...
here goes.. i want to write a shell script to take interleave the lines of a file with another.. i.e. --------------------- file1.txt: 1 2 3 ------------------- file2.txt 10 11 12 -------------------- to produce another file.. 1 10 11 12 2 10 11 12 3 10 11 12 ----------------------- where would i start on how to learn to do this, or has anyone got a simple solution or idea that might help thanks in advance :) james |
cat file1 | while read a; do echo $a; cat file2 | while read b; do echo $b; done; done
|
Or save a loop and simply type:
cat file1 | while read a; do echo $a;cat file2;done Happy hacking |
blinding.. thankyou :)
ill have a go and let you know.. james |
first one works beutifully, second one leave the lines from the first file, tagged onto the ends of the lines of the second file..
is there any way i can insert characters into the sequence? i.e. insert tabs before the lines of the second file to lay them out tree style.. :) james |
Or save a loop and simply type:
cat file1 | while read a; do echo $a;cat file2;done" that's even better! _____________________________ "first one works beutifully, second one leave the lines from the first file, tagged onto the ends of the lines of the second file.." second one should work also, sounds like you don't have a newline at the end of the second file _____________________________ "is there any way i can insert characters into the sequence? i.e. insert tabs before the lines of the second file to lay them out tree style.." cat file1 | while read a; do echo $a; cat file2 | sed 's/^/\t/'; done |
All times are GMT -5. The time now is 02:58 PM. |