file1.txt
is like:
$view->name = '12483291';
...
$view->human_name = '12483291';
Also I have some numbers in file2
:
8789
53416
673425
What I need to do is: for each number in the above column, replace the '12483291' value, and create a new file named after the replacement number.
Desired output:
file: 8789.inc
$view->name = '8789'
...
$view->human_name = '8789'
file: 53416.inc
$view->name = '53416'
...
$view->human_name = '53416'
file: 673425.inc
$view->name = '673425'
...
$view->human_name = '673425'
How would you approach this?
A few of my attempts, but without getting the result I want:
sed "s/12483291/$(cat file2)/" file1 > 8789.inc
The above works if file2
has only one line, and I have to run the command as many times as the values in file2
, manually giving the name of the result file.