*nix shell script symbols

Thread Solved

Join Date: Jun 2009
Posts: 10
Reputation: curi0x is an unknown quantity at this point 
Solved Threads: 0
curi0x curi0x is offline Offline
Newbie Poster

*nix shell script symbols

 
0
  #1
Jul 6th, 2009
hi. I'm a newbie in shell scripting as well as the *nix OS.

I just wanna ask about the symbol #! that I saw in many shell script examples. For instance, #!/bin/bash . What does the #! symbol means?

What's the meaning of $1, $2, $3 symbols?
and what does the symbol ~ (like in cd ~user_name ) means?

I'm sorry if this question sounds stupid and if my English is bad. English isn't my native languange.

Please help..
Last edited by curi0x; Jul 6th, 2009 at 10:04 am.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,354
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 252
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: *nix shell script symbols

 
0
  #2
Jul 6th, 2009
#! is a built-in exec. The shell script is executed in the shell declared on this line.

$1 etc are the arguments provided on the command line (or provided on the function call when used inside a function)

~ means home directory.

And I hope this is not homework.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 10
Reputation: curi0x is an unknown quantity at this point 
Solved Threads: 0
curi0x curi0x is offline Offline
Newbie Poster

Re: *nix shell script symbols

 
0
  #3
Jul 6th, 2009
no. this isn't homework. I saw it in the facebook's puzzle master discussion. I'm using windows, and never use *nix OS before. thanks for your help.

by the way, I forgot to ask about $< and $@ symbol. Do you know what it means?
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,354
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 252
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: *nix shell script symbols

 
0
  #4
Jul 6th, 2009
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 10
Reputation: curi0x is an unknown quantity at this point 
Solved Threads: 0
curi0x curi0x is offline Offline
Newbie Poster

Re: *nix shell script symbols

 
0
  #5
Jul 6th, 2009
thank you so much!
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,187
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 571
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: *nix shell script symbols

 
0
  #6
Jul 6th, 2009
Originally Posted by curi0x View Post
I just wanna ask about the symbol #! that I saw in many shell script examples. For instance, #!/bin/bash . What does the #! symbol means?
It is also called a "shebang":
http://en.wikipedia.org/wiki/Shebang_(Unix)
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Shell Scripting Forum
Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC