Re: OT: Which tool, and how, to get partial string from file?
Miquel van Smoorenburg wrote:
Here's my test script:
#!/bin/bash
if [ sed -ne 's/^.*\(icewm\).*$/\1/p' < /home.local/snert/.xinitrc ] ;
then
echo "Yep"
else
echo "Nope"
fi
That's the complete wrong way to use '[' !
I'm not sure what you mean here; if you mean it lacks readability then I
agree with you.
You want something like:
WORD=`sed -ne 's/^.*\(icewm\).*$/\1/p' < /home.local/snert/.xinitrc`
but for readability, don't use back-ticks. Instead
WORD=$(sed -ne 's/^.*\(icewm\).*$/\1/p' < /home.local/snert/.xinitrc)
which is more readable, allows you to span lines and even to nest (in
moderation) while maintaining some semblance of clarity.
I think it's ours vs yours in baseball this evening.
--
Cheers
John
-- spambait
1aaaaaaa@computerdatasafe.com.au Z1aaaaaaa@computerdatasafe.com.au
Tourist pics http://portgeographe.environmentaldisasters.cds.merseine.nu/
Reply to: