943,829 Members | Top Members by Rank

Ad:
Jan 19th, 2009
0

What's the difference between "\command" and "command"?

Expand Post »
Hi,
I read something like "\mkdir ${RESULT_DIR}". Just curious about why "\" is added before the command? Thanks for help!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
lehe is offline Offline
36 posts
since Jul 2008
Jan 19th, 2009
0

Re: What's the difference between "\command" and "command"?

It typically represents a new line. Try it at a command line... type in say: mkdir \
your prompt will probably change to >, which means the command is not complete yet, and requests more info. I don't know the context or the script, so it makes it a little more difficult to explain.
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Jan 19th, 2009
0

Re: What's the difference between "\command" and "command"?

I think it is not a newline. Here goes the context:

if [[ -d ${RESULT_DIR} ]]; then
echo "Directory ${RESULT_DIR} already exists."
exit 1
fi

\mkdir ${RESULT_DIR}

if [[ ! -d ${RESULT_DIR} ]]; then
echo "Can not find ${RESULT_DIR}"
exit 1
fi
Reputation Points: 10
Solved Threads: 0
Light Poster
lehe is offline Offline
36 posts
since Jul 2008
Jan 19th, 2009
1

Re: What's the difference between "\command" and "command"?

Without the backslash, the shell checks to see if there is an alias for the command. If so, it uses it.

With the backslash, the shell skips this check and runs the first version of the command that it finds in $PATH.

N
Reputation Points: 51
Solved Threads: 35
Posting Whiz in Training
Fest3er is offline Offline
238 posts
since Aug 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Shell Scripting Forum Timeline: help with sed and file
Next Thread in Shell Scripting Forum Timeline: Confused on how to set multiple variables while asking for user input in a loop...





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC