File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Linux / UNIX
compare OS command with String value in Shell Script ?
Joined: Apr 08, 2004
Jul 10, 2011 20:42:40
How to compare OS command pwd with
value in Shell Script ?
if [ "$cudir" == "etc" ]; then
echo "You are in etc"
echo "some other"
Joined: May 14, 2008
Jul 11, 2011 08:57:34
I think the first line should be (those are backwards single quotes, or ticks, around pwd):
cudir = `pwd`
JBoss In Action
author and jackaroo
Joined: Mar 28, 2003
Jul 11, 2011 09:46:45
And remove the spaces around that first equal sign:
A more readable solution (and one that allows greater flexibility) is to use the alternate construct:
Remember that this will give the path from the root directory. Therefore your if statement will also need to refer to the full directory:
if [ "$cudir" == "/etc" ];then
The Sun Certified Java Developer Exam with J2SE 5:
paper version from Amazon
PDF from Apress
, Online reference:
I agree. Here's the link:
subject: compare OS command with String value in Shell Script ?
Maximum length of Command Line Argument
Echo value capture in .sh script
split function problem in AWK
how to set classpath
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015