top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

How comments are processed in shell script?

0 votes
24 views

I have noticed that in shell script comments are also useful to perform some task,
for ex:
if i write #!/bin/bash/
or if i write #!/bin/sh/

in both the example script behavior is different,
both are comments then why it is giving different behavior?

posted Aug 18, 2015 by Chirag Gangdev

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

1 Answer

0 votes

Its just a convention i.e. #! (its not #, its #!) to tell what type of the shell/interpreter it is. Your scripts can be in bash, python, perl, ruby, PHP etc by the following means

#!/bin/bash
#!/bin/sh
#!/bin/perl
#!/bin/perl5
answer Aug 18, 2015 by Salil Agrawal
Similar Questions
+2 votes

I am using below script to validate IPV6 address but this script also pass invalid IP such as empty string, name etc.

if [[ "$IPv6ADDR"=~"^:?([a-fA-F0-9]{1,4}(:|.)?){0,8}(:|::)?([a-fA-F0-9]{1,4}(:|.)?){0,8}$" ]]; then
  echo "valid ipv6 addr"
  break;
else
  echo "Invalid IP Address"
  break;
fi

Can someone identify what's wrong in the regex, Please?

0 votes

I have a shell script copyScript.sh present in my pendrive.
What i want is, Whenever i connect pendrive to my pc this script should be run automatically.

Is it possible?
If yes then how to achieve this?

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...