$ cat foo.txt foor barr bazz quux $ perl -lpi.bak -e 's/bar/rab/ if $.==2' foo.txt $ cat foo.txt foor rabr bazz quux