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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
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
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
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

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
omarfaridCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nilehawkAuthor Commented:
thanks you for your help
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.