1

Hi I am having some problems with this.

I have a original file:

$cat original.txt
User has access to the system

And a second file with the content I want to add to the original file:

$cat toAdd.txt
Anna

The result should be as follows:

$cat original.txt
User Anna has access to the system

I tried with several options such as:

sed '/has/e cat toAdd.txt' original.txt

but it is not working :-(

Please help!!

MrTeleBird
  • 151
  • 7

1 Answers1

1

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 to the system
Avinash Raj
  • 172,303
  • 28
  • 230
  • 274