Why rescan the input 4-times to change the l,i,n,u,x? Instead, use sed ‘s/L/l/;s/n/N/;s/l/L/;s/x/X/‘?
I’ll have to play w/-i … it feels dangerous 😟 -i.bak makes me feel more comfortable, though. 😊
I spent a couple of hours yesterday writing a 1-liner listing a java project’s exposed endpoints and their HTTP methods, based on @.*Mapping annotations.
I've been a professional C, Perl, PHP and Python developer.
I'm an ex-sysadmin from the late 20th century.
These days I do more Javascript and CSS and whatnot, and promote UX and accessibility.
Been using UNIX since the late 80s; Linux since the mid-90s; virtualization since the early 2000s and spent the past few years working in the cloud space.
Location
Alexandria, VA, USA
Education
B.S. Psychology from Pennsylvania State University
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".
Why rescan the input 4-times to change the l,i,n,u,x? Instead, use
sed ‘s/L/l/;s/n/N/;s/l/L/;s/x/X/‘?I’ll have to play w/
-i… it feels dangerous 😟-i.bakmakes me feel more comfortable, though. 😊I spent a couple of hours yesterday writing a 1-liner listing a java project’s exposed endpoints and their HTTP methods, based on
@.*Mappingannotations.It's just a demonstration of piping, I don't think it's intended to be optimal. You could just do
echo Linux | tr 'nx' 'NX'if you wanted that.What's this dark magic? O.o
Guess I just missed that one.
It is indeed. Once I messed up some logs files that I was going through.
Similarly, have single-invocation choices like:
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.
...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".
intention was just to demonstrate piping :)