Skip to main content
add a suggestion from comment to make the solution more generic
Source Link
exore
  • 261
  • 1
  • 6
sed -ne '1,/^jum/{s/^jum//p;d;}' -e p

As @Sundeep states in comment, if you have GNU sed, use preferably sed -ne '0,/^jum/{s/^jum//p;d;}' -e p. This would work even if jum on the first line. which is not the case with 1,/^jum/.

Here is what it does:

  • sed -n: don't print anything unless told to
  • 1,/^jum/: for lines between the 1st one and the one that starts with jum inclusive:
    • s/^jum//p: if you can remove "jum" at start of line, print the result
    • d: and proceed with next line
  • -e p: all other lines, just print them.
sed -ne '1,/^jum/{s/^jum//p;d;}' -e p

Here is what it does:

  • sed -n: don't print anything unless told to
  • 1,/^jum/: for lines between the 1st one and the one that starts with jum inclusive:
    • s/^jum//p: if you can remove "jum" at start of line, print the result
    • d: and proceed with next line
  • -e p: all other lines, just print them.
sed -ne '1,/^jum/{s/^jum//p;d;}' -e p

As @Sundeep states in comment, if you have GNU sed, use preferably sed -ne '0,/^jum/{s/^jum//p;d;}' -e p. This would work even if jum on the first line. which is not the case with 1,/^jum/.

Here is what it does:

  • sed -n: don't print anything unless told to
  • 1,/^jum/: for lines between the 1st one and the one that starts with jum inclusive:
    • s/^jum//p: if you can remove "jum" at start of line, print the result
    • d: and proceed with next line
  • -e p: all other lines, just print them.
Source Link
exore
  • 261
  • 1
  • 6

sed -ne '1,/^jum/{s/^jum//p;d;}' -e p

Here is what it does:

  • sed -n: don't print anything unless told to
  • 1,/^jum/: for lines between the 1st one and the one that starts with jum inclusive:
    • s/^jum//p: if you can remove "jum" at start of line, print the result
    • d: and proceed with next line
  • -e p: all other lines, just print them.