•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 402,918 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,205 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser: Programming Forums
Views: 500 | Replies: 2 | Solved
![]() |
•
•
Join Date: Nov 2007
Posts: 107
Reputation:
Rep Power: 1
Solved Threads: 0
if [ "$1"="-s" -a -n "$2" ] # if $1 is string "-s" and $2 is not null
then
string="$2" # then string="$2"
else
echo "error"
exit 1
fi
echo $string
i expect: foo -not"-s" hi return "error"
however,, no matter what i type after the - , the test will return true. why is that?
i already tried para=`echo "$@"` ; set -- $para still not working properly
•
•
Join Date: Oct 2007
Posts: 267
Reputation:
Rep Power: 1
Solved Threads: 26
Hey there,
You just need to change the
to
with space on both sides of the = operator and it works well
Best wishes,
Mike
You just need to change the
•
•
•
•
"$1"="-s"
to
•
•
•
•
"$1" = "-s"
with space on both sides of the = operator and it works well

Best wishes,
Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
![]() |
•
•
•
•
•
•
•
•
DaniWeb Shell Scripting Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- help with an sql statement (MS SQL)
- IF statement question (Java)
- Question about synchronized and wait (Java)
- Noobie Question (sry) (C++)
- Good Luck w/This one: Excel Question VBA/Macro/other (MS Access and FileMaker Pro)
- help clear mess in single-scripted array (C++)
- how to do something special with this question (C++)
- DataTable Name question (VB.NET)
Other Threads in the Shell Scripting Forum
- Previous Thread: begin 644 msg from script sending file
- Next Thread: Automating sftp (script) to copy files


Linear Mode