I'd like to do this using Perl command line (sorry no awk, sed, etc.)
replace the 3 middle lines in a file by one line:
aaa 123
bbb 234
ccc 34567
dd 4567
ee 567
to:
aaa 123
AAA
ee 567
I tried this but not working:
perl -pi -e "s/aaa\ 123\nbbb\ 234\nccc\ 34567/AAA/" file
any ideas?
You'll need to enable slurp mode in order to work with multiple lines -
$
$
$ cat f2
aaa 123
bbb 234
ccc 34567
dd 4567
ee 567
$
$
$ perl -pne 'BEGIN {undef $/} s/bbb 234\nccc 34567\ndd 4567/AAA/' f2
aaa 123
AAA
ee 567
$
$
$
tyler_durden
Thanks durden_tyler. that worked !