awk - linux insert file content before string match -
this question has reply here:
sed insert file content after specific pattern match 1 replyhi having problems this.
i have original file:
$cat original.txt user has access scheme
and sec file content want add together original file:
$cat toadd.txt anna
the result should follows:
$cat original.txt user anna has access scheme
i tried several options such as:
sed '/has/e cat toadd.txt' original.txt
but not working :-(
please help!!
through awk,
$ awk 'fnr==nr{var=$0; next}{for (i=1;i<=nf;i++){if($i=="has"){$i=var" "$i}}}1' toadd.txt original.txt user anna has access scheme
linux awk sed
No comments:
Post a Comment