alias_qr_rainmaker@lemmy.world to linuxmemes@lemmy.world · 2 days agoEven better than the originallemmy.worldimagemessage-square12fedilinkarrow-up199arrow-down13
arrow-up196arrow-down1imageEven better than the originallemmy.worldalias_qr_rainmaker@lemmy.world to linuxmemes@lemmy.world · 2 days agomessage-square12fedilink
minus-squareBadabinski@kbin.earthlinkfedilinkarrow-up10·2 days agono pipe necessary, just sed -E 's/TH|[EL ]|DO//g' <<<"$line"
minus-squareh4x0r@lemmy.dbzer0.comlinkfedilinkEnglisharrow-up8·2 days agoNo sed necessary with extglob enabled: echo ${line//@(TH|[EL ]|DO)/}
minus-squareBadabinski@kbin.earthlinkfedilinkarrow-up3·2 days agoI was waiting for someone to come along with this response lmao I’m terrible at remembering shell string operation syntax, but this is the ultimate answer.
minus-squaresik0fewl@lemmy.calinkfedilinkarrow-up2arrow-down1·2 days agoDefinitely not the ultimate, since it’s not POSIX, but still a nice tidbit.
minus-squareBadabinski@kbin.earthlinkfedilinkarrow-up3·2 days agoIdk, writing POSIX-compliant shell is so miserable that I avoid doing it when I can. You can use Bash on BSD and all other unixes, so it’s still a relatively portable solution.
minus-squaresik0fewl@lemmy.calinkfedilinkarrow-up2arrow-down1·2 days agoTrue enough, but it’s pretty much the same to use sed, unless you need those milliseconds of performance boost.
minus-squarea_non_monotonic_function@lemmy.worldlinkfedilinkarrow-up2arrow-down1·2 days agoI think I find the pipe faster to parse.
minus-squareBadabinski@kbin.earthlinkfedilinkarrow-up1·1 day agoidk who downvoted you, it’s a very common sentiment. I advocate for <<<, but a pipe is often fine when performance doesn’t matter.
minus-squarea_non_monotonic_function@lemmy.worldlinkfedilinkarrow-up2·1 day agoPerformance doesn’t really matter with any of my scripts. They’re mostly for personal use. And the even funnier thing is getting downvoted for a style preference. XD
no pipe necessary, just
sed -E 's/TH|[EL ]|DO//g' <<<"$line"No
sednecessary withextglobenabled:echo ${line//@(TH|[EL ]|DO)/}I was waiting for someone to come along with this response lmao
I’m terrible at remembering shell string operation syntax, but this is the ultimate answer.
Definitely not the ultimate, since it’s not POSIX, but still a nice tidbit.
Idk, writing POSIX-compliant shell is so miserable that I avoid doing it when I can. You can use Bash on BSD and all other unixes, so it’s still a relatively portable solution.
True enough, but it’s pretty much the same to use sed, unless you need those milliseconds of performance boost.
I think I find the pipe faster to parse.
idk who downvoted you, it’s a very common sentiment. I advocate for
<<<, but a pipe is often fine when performance doesn’t matter.Performance doesn’t really matter with any of my scripts. They’re mostly for personal use.
And the even funnier thing is getting downvoted for a style preference. XD