command line explanation

Hello everyone,

I found this command line in a website:

perl -pi.bak -we's/\z/Your new line\n/ if $. == 2;' your_text_file.txt

With this command line you can insert a new line anywhere you want in a text without overwriting what's in it.

-p causes perl to assume a loop around your file so that you can process it.
i.bak creates a back up file
-w turns on warnings.
-e is the script you want to execute.

Does anyone know what s/\z/ is for?

Thanks a lot.

\z matches at the end of the string...See here...

so as I read this, it will substitute the end of the string for Your New Line followed by carriage return on line 2

Thank you for your reply JerryHone

One last question.
What do you mean by carriage return?

Slip up on my part...\n is officially a newline character - ASCII LF = 0x0A. \r is officially the carriage retrurn character CR = 0x0D.

Entering a "\n" in a string is equivalent to entering the "Return" or "Enter" key on the keyboard.

Thank you