Re:Advanced Shell Scripting Techniques: Automating Complex T...
by metadat on Tuesday June 18, 2024 @09:22PM
(#40723827)
Shouldn't the first one be `grep -F/--fixed-strings "${partition}"? The second example will break in any case where $partition contains special characters.
[ Parent
| on HN ]
Re:Advanced Shell Scripting Techniques: Automating Complex T...
by oguz-ismail on Tuesday June 18, 2024 @10:05PM
(#40724082)
Yes, it's an easy fix though:
df -h | grep -Po "\d+(?=%\s+\Q$partition\E)"
Re:Advanced Shell Scripting Techniques: Automating Complex T...
by metadat on Tuesday June 18, 2024 @10:19PM
(#40724131)
Oh cool, this is the first time I've heard of `grep \Q..\E'
https://stackoverflow.com/questions/54405892/are-q-and-e-sup...
Thanks!
At some point I should probably write an article about the 20k lines of bash and a little python that power my homelab and various automations. Bash isn't perfect but often 99% good enough is fine.