merge, past, and parse text files

i want to merge first row from file1, file2, file3, .. fileM into new_file
then copy this first row from <new_file>
then past it into row1,row2,.. rowN

also how can i call vi within my script to perform some tasks i.e replacing characters,past, delete,... etc
please advise
thank you
nilehawkAsked:
Who is Participating?
 
omarfaridConnect With a Mentor Commented:
you don't need sed for that, try

#!/usr/bin/bash
line=`head -1 assembled fie_new`
c=1
while test $c -le 10
do
    echo $line >> an_other_file
    c=`expr $c + 1`
done

or

#!/usr/bin/bash
line=`head -1 assembled fie_new`
echo $line >> an_other_file
echo $line >> an_other_file
echo $line >> an_other_file
echo $line >> an_other_file
echo $line >> an_other_file
echo $line >> an_other_file
echo $line >> an_other_file
echo $line >> an_other_file
echo $line >> an_other_file
echo $line >> an_other_file
0
 
ozoConnect With a Mentor Commented:
paste  file1 file2 file3 fileM > new_file
0
 
nilehawkAuthor Commented:
thanks ozo,
yes, it is working ok but still want to know how can i call vi in my script to make copy and past from new_file
i need after merging these file to copy this row and past it several times
thanks
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
omarfaridCommented:
vi is an interactive editor that needs terminal to be used. So far I did not come across scripts that call vi and pass commands to it.

You may alternatively use ed, ex, or sed.

0
 
nilehawkAuthor Commented:
thanks omarfarid
how can i use sed for copy and past lines?
0
 
nilehawkAuthor Commented:
thanks omarfarid
how can i use sed for copy and past lines?
0
 
omarfaridCommented:
here a link to sed tutorial

http://www.grymoire.com/Unix/Sed.html#uh-37

what exactly you want to copy?
0
 
nilehawkAuthor Commented:
i want to copy first row in the assembled fie_new and past it at the end of an_other_file 10 successive times
0
 
nilehawkAuthor Commented:
thanks you for your help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.