help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Brace expansions in if statement


From: Marco Silva
Subject: Re: [Help-bash] Brace expansions in if statement
Date: Thu, 29 Mar 2018 16:02:54 -0300
User-agent: Sup/0.22.1

Excerpts from Felipe Salvador's message of 2018-03-29 20:12:21 +0200:
> Hi list,
> I'm trying to make bash to expand a brace expansion in a if statement.
> 
> So, I've
> 
>        if [ "$GTTY" = tty{0..10} ]; then
>        msger=echo
>        else
>        msger=notify-send
>        fi
> 
> where $GTTY is $(tty | cut -d'/' -f3).
> It doesn't work.
> I'm reading allot of web pages, but I cannot get over.
> Could you please help me?
> 
> Kind regards

That won't work. tty{0..10} . You want a OR operation to all
= tty{0..10}

you can write:

echo tty{0..10} | while read term; do
if [ "$GTTY" == "$term" ]; then
    msger=echo
    break
done

msger="${msger:-notify-send}

for same behaviour.

-- 
Marco Arthur @ https://optdyn.com



reply via email to

[Prev in Thread] Current Thread [Next in Thread]