Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Condition 1

Status
Not open for further replies.

Yarka

Technical User
Jan 14, 2007
192
ES
Hi,
I've a trouble when I execute :

if [ [ ${a}%5 = 0 && ${b}%10 = 1 ] ]; then

How can I do this?

Thanks.
 
What about this ?
if [[ $((a%5)) = 0 && $((b%10)) = 1 ]]; then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi,
In fact, I want to do something as:

cat $1 | while read LINE; do

read LINE
a=`echo "$LINE" | awk -F'\t' '{ print $5 }'`
a=${a:3:2}

if [[ $((a%5)) = 0 && $((a%10)) = 1 ]]; then
.....
echo "if case"
else
.....
echo "else case"
fi
done

But this check is wrong, because for example if a=25 my output is else case and not if case.

Thanks.
 
if [[ $((a%5)) -eq 0 && $((a%10)) -ne 0 ]]; then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
This works well, but sorry, if I want to do he negation of the expression:

if [[ $((a%5)) -eq 0 && $((a%10)) -ne 0 ]]; then

How can I do this?

Thanks.
 
Either:
if [[ ! ($((a%5)) -eq 0 && $((a%10)) -ne 0) ]]; then
or:
if [[ $((a%5)) -ne 0 || $((a%10)) -eq 0 ]]; then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top