[Sugar-devel] Quoting in shell scripts (was: Re: [sugar-devel] Recent fiddlings with Print Support)
Martin Langhoff
martin.langhoff at gmail.com
Thu May 14 04:33:09 EDT 2009
On Thu, May 14, 2009 at 8:14 AM, Andrés Ambrois <andresambrois at gmail.com> wrote:
> if [ -z `grep "%!PS-Adobe-3.0" < "$fn2"` ]; then
Even better, you can use the exit code of grep, thus
if grep -q 'pattern' $file; then
elegant, clearer and faster :-)
Some grep implementations don't support -q, so a more portable way
(but uglier) of saying the same is:
if grep 'pattern' $file >/dev/null ; then
(Actually, some take -s for 'silent', but that's patchy as well. Only
/dev/null works everywhere...)
cheers,
m
--
martin.langhoff at gmail.com
martin at laptop.org -- School Server Architect
- ask interesting questions
- don't get distracted with shiny stuff - working code first
- http://wiki.laptop.org/go/User:Martinlanghoff
More information about the Sugar-devel
mailing list