Extract some lines from one file and add those lines to current file

hi,

i have two files.

file1.sh

echo "unix"
echo "linux"

file2.sh

echo "unix linux forums"

now the output i need is

$./file2.sh
unix linux forums
$
$./file1.sh
unix
linux
unix linux forums
$

i want extract that line in file2.sh and add it to first line and also execute that one.

i need following

$vi file1.sh
echo "unix"
echo "linux"
<script to exarct and execute some lines from file2> 

Hi
Not sure whether I got your question correctly.

$ cat file1.sh
echo "unix"
echo "linux"
x=`awk 'NR==1' file2.sh`
eval $x

In place of '==1', you can put the appropriate line number which you want to extract.

Output:

$ ./file1.sh
unix
linux
unix linux forums

Guru.

1 Like

Try this:

file3.sh
echo "unix" echo "linux"
echo `file2.sh`

thanks guruprasadpr for your useful reply.