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

Reply

Join Date: Jul 2008
Posts: 36
Reputation: lehe is an unknown quantity at this point 
Solved Threads: 0
lehe lehe is offline Offline
Light Poster

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

 
0
  #1
Jan 19th, 2009
Hi,
I read something like "\mkdir ${RESULT_DIR}". Just curious about why "\" is added before the command? Thanks for help!
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

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

 
0
  #2
Jan 19th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 36
Reputation: lehe is an unknown quantity at this point 
Solved Threads: 0
lehe lehe is offline Offline
Light Poster

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

 
0
  #3
Jan 19th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 165
Reputation: Fest3er is an unknown quantity at this point 
Solved Threads: 18
Fest3er Fest3er is offline Offline
Junior Poster

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

 
1
  #4
Jan 19th, 2009
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC