LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   sed command '1s/^/File: /;1!s/^/+ /' (https://www.linuxquestions.org/questions/linux-newbie-8/sed-command-1s-%5E-file-%3B1-s-%5E-4175713133/)

Faki 06-07-2022 08:35 PM

sed command '1s/^/File: /;1!s/^/+ /'
 
What does this sed command do? I see that it adds "File: " or "+ ", but is not straightforward to determine when the expressions are inserted.

Code:

sed '1s/^/File: /;1!s/^/+ /'

michaelk 06-07-2022 09:06 PM

Lets start with https://www.gnu.org/software/sed/manual/sed.html

Basically 1 is line one and 1! is all lines but line 1.


All times are GMT -5. The time now is 03:42 PM.