sed
can print the line numbers you want:
$ printf $'foo\nbar\nbaz\n' | sed -ne '2p' bar
If you want some lines:
$ printf $'foo\nbar\nbaz\n' | sed -ne '2p;3p' bar baz
To convert a rowset to a sed
command like this, use sed
for a nice sed
ception:
$ printf $'98\n101' | sed -e 's/$/;/' 98; 101;
Putting it all together:
sed -ne "$(sed -e 's/$/p;/' B)" A
Testing:
$ cat A 1 22 333 4444 $ cat B 1 3 $ sed -ne "$(sed -e 's/$/p;/' B)" A 1 333
QED
source share