[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Conditional actions according to user input
From: |
alex xmb ratchev |
Subject: |
Re: Conditional actions according to user input |
Date: |
Sun, 23 Apr 2023 10:35:35 +0200 |
to make globs act instead of flat text , dont quote em
arr=( "*.ext1" "*.ext2" )
for f in ${arr[@]} ; do ..
or for i in "${arr[@]}" ; do
files=( $i )
or just at beginning
arr=( *.1 *.2 )
u seem to have -p or -q somewhere at end , u can
pary=( "-p+([[:digit:]])" "-g+([[:digit:]])" "-q" )
files=( ${pary[@]/#/*.} )
or , u go manually thru the list ?
for glob in "${pary[@]}" ; do
if [[ $glob == "-q" ]] ; then # quote
files=( *.$glob ) # noquote
fi
done
greets
On Sun, 23 Apr 2023, 6:28 am uzibalqa, <uzibalqa@proton.me> wrote:
> I have a set of possible user input formats stared in an array
>
> For instance
>
> pary=( "-p+([[:digit:]])" "-g+([[:digit:]])" "-q" )
>
> I then want to match these with the actual user inputs
>
> for gpn in "${pary[@]}"
> do
> if [[ "$arg" == $gpn ]]; then
>
>
> What I do after is dependent on whether the user used the digit form (e.g
> "-p+([[:digit:]])")
> or the isolated predicate form (e.g. "-q").
>
> How can I handle the aforementioned functionality in a clear and compact
> way?
>
>
>
>
>
>
Re: Conditional actions according to user input,
alex xmb ratchev <=
Re: Conditional actions according to user input, alex xmb ratchev, 2023/04/23
Re: Conditional actions according to user input, alex xmb ratchev, 2023/04/23