DEV Community

Discussion on: Processing Text with Linux Shell - Part 1

Collapse
 
ferricoxide profile image
Thomas H Jones II • Edited

Similarly, have single-invocation choices like:

echo Linux | sed -e 's/L/l/'-e 's/n/N/'-e 's/l/L/' -e 's/x/X/'

Which, to me, is more readable than having everything all bunched up and lends itself to uniform line-breaking in a long, complex script. Similarly, if you go this route, you also improve readability while retaining the "single invocation" efficiencies.

echo Linux | sed '{
   s/L/l/
   s/n/N/
   s/l/L/
   s/x/X/
}

...Though, if you're transforming the "L" to an "l" and then back to an "L", efficiency likely isn't your goal.

Whether using multiple, discreet sed invocations or a single, multi-transform sed, always remember that "order counts".

Collapse
 
shamil profile image
Shamil

if you're transforming the "L" to an "l" and then back to an "L", efficiency likely isn't your goal.

intention was just to demonstrate piping :)