I\'m trying to write a bash script, which will do the following:
This should work:
perl -lne 'BEGIN{open(A,"first_file.txt");@f=;}print;if(/2222/){print @f}' second_file.txt
Tested:
> cat temp
111111
1111
11
1
> cat temp2
122221
2222
22
2
> perl -lne 'BEGIN{open(A,"temp");@f=;}print;if(/2222/){print @f}' temp2
122221
111111
1111
11
1
2222
111111
1111
11
1
22
2
>