Reputation: 15
for example
a=1;b=2;c=3;d=4;e=5
the file is 1.sh
cat 1.sh
echo $a
echo $b
echo $c
echo $d
echo $e
i use the command
source 1.sh
i get
1
2
3
4
5
how can i source the last 3 line of 1.sh?
tail -n 3 1.sh|xargs -0 sh -c
can not work because the variable can not pass to sh
Upvotes: 0
Views: 91
Reputation: 263627
tail -n 3 1.sh > tmp.sh ; source ./tmp.sh ; rm tmp.sh
If necessary, choose or generate a name that's unlikely to collide with anything else, like /tmp/tmp$$.sh
.
Upvotes: 1