Author

Topic: what is this #!/bin/bash (Read 183 times)

newbie
Activity: 37
Merit: 0
June 04, 2018, 03:17:09 PM
#10
what is this #!/bin/bash,  I could not understand it, through cpp,

This is shell script, Shell has many version and first line of code "#!/bin/ is to  tell to which type of shell is used to execute that script.
The most  famous shell are korn shell (ksh) and bash shell (shell). Although unix scripts can execute in all shells but some commands (very small list) are very specific to that shell type so we need to give shell type in accordance.

Otherwise "#" is used to comment in unix (if it is not first line in script and it is first character of that line).

thank you very much that was helpfull
full member
Activity: 198
Merit: 130
Some random software engineer
June 04, 2018, 12:19:04 PM
#9

Code:
date +%s.%N | sha256sum | base64 | head -c 32 ; echo
 



Smiley

Code:
cat /dev/urandom | tr -dc 'A-Za-z0-9!"#$%&'\''()*+,-./:;<=>?@[\]^_`{|}~' | head -c 28 | sha256sum | base64 | head -c 32 && echo ""

Code:
$ sudo apt install pwgen
$ pwgen
eiGh8voe eec7Gohc AhJ7euro ef2Riiz8 Saej7Oz3 dim3ahBo eitoo6Uo weeP3zea
oop4UW4o Eiza8ooH shaeH8Ph pau6oaNg AeN4kie3 HaiPu7oh Ne5sahNg Sei2ahSe
eet7Oor6 rohNg7yo yie8Ahsh Dahn6ooy choo5ieG ahM9ukai Em4ox2Pu Eiphan4o

(Fedora/Centos version is for sure dnf install -y pwgen)
Cheers.
jr. member
Activity: 44
Merit: 2
June 04, 2018, 05:48:38 AM
#8

Code:
date +%s.%N | sha256sum | base64 | head -c 32 ; echo
 



Smiley

Code:
cat /dev/urandom | tr -dc 'A-Za-z0-9!"#$%&'\''()*+,-./:;<=>?@[\]^_`{|}~' | head -c 28 | sha256sum | base64 | head -c 32 && echo ""
jr. member
Activity: 168
Merit: 3
#Please, read:Daniel Ellsberg,-The Doomsday *wk
June 04, 2018, 05:04:07 AM
#7
bash is the debian / ubuntu and other major linux distribution command line interface, all system and application commands are executed through the shell.

for ex ./myscript.sh launches a script.
You can pipe/ manipulate in/output in bash , for example using sed, awk or grep or inbuilt options see for example:
Code:
https://www.thegeekstuff.com/2010/07/bash-string-manipulation/
You also can automate almost any system task using shell scripts Smiley
May read this
Code:
https://github.com/awesome-lists/awesome-bash



Good script,
*nix still "the system" since Thursday, 1 January 1970, according my time-travel colleges John T, Barry Allen, et al .. Yes the cool thing about UTCnix pipe-lining is that you can concatenation of commands using the ascII symbol |

For instance sometimes I want to generate a one-time password-nonce in order to no be so obvious across various websites ..

so I can go using BTCash
Code:
date +%s.%N | sha256sum | base64 | head -c 32 ; echo
 

hope it can be useful.
ps->Sure sky is the limit if you have a huge imagination  Wink
jr. member
Activity: 44
Merit: 2
June 04, 2018, 04:04:47 AM
#6
bash is the debian / ubuntu and other major linux distribution command line interface, all system and application commands are executed through the shell.

for ex ./myscript.sh launches a script.
You can pipe/ manipulate in/output in bash , for example using sed, awk or grep or inbuilt options see for example:
Code:
https://www.thegeekstuff.com/2010/07/bash-string-manipulation/
You also can automate almost any system task using shell scripts Smiley
May read this
Code:
https://github.com/awesome-lists/awesome-bash

AGD
legendary
Activity: 2070
Merit: 1164
Keeper of the Private Key
June 04, 2018, 01:17:44 AM
#5
what is this #!/bin/bash,  I could not understand it, through cpp,

It doesn't matter as long as you understand the rest of the code.

If you want to start coding and got stuck at shebang, you got a very long way ahead of you, jus sayn
jr. member
Activity: 168
Merit: 3
#Please, read:Daniel Ellsberg,-The Doomsday *wk
June 03, 2018, 10:54:34 PM
#4
Honestly, I am not a language specialist but I have a slightly preference for languages like ADA.

from my textbook

Quote
Dealing with overflows and underflows
Because overflows and underflows can cause serious problems, some
programming languages, such as Ada, proactively trigger an exception
condition to alert the user that an underflow or overflow has occurred as the
program is running. Others, such as C and C++, do not specify what will
happen should an underflow or overflow occur, which means that the
programmer cannot rely on getting any warning, or even consistent behaviour
as their program is executing. Python, alongside some other programming
languages, automatically bumps up the amount of storage as necessary to
reduce the risk of an underflow or overflow occurring.
Underflow and overflow situations can cause serious problems. In May 2015,
the BBC published a story about the potential dangers of the Boeing 787
airplane engines switching themselves off mid-flight. The potential problem
was found to be a 4-byte memory location that held a ‘count’ of how long
the engines had been fired up. Calculations showed that this memory location
would go into overflow sometime after the 248th day of continuous running,
potentially causing the engines to lose power while in flight. Boeing
immediately issued directives to ensure that the counters were regularly reset
while they developed a software solution.
sr. member
Activity: 742
Merit: 395
I am alive but in hibernation.
June 03, 2018, 09:09:50 PM
#3
what is this #!/bin/bash,  I could not understand it, through cpp,

This is shell script, Shell has many version and first line of code "#!/bin/ is to  tell to which type of shell is used to execute that script.
The most  famous shell are korn shell (ksh) and bash shell (shell). Although unix scripts can execute in all shells but some commands (very small list) are very specific to that shell type so we need to give shell type in accordance.

Otherwise "#" is used to comment in unix (if it is not first line in script and it is first character of that line).
full member
Activity: 198
Merit: 130
Some random software engineer
June 03, 2018, 04:14:38 PM
#2
what is this #!/bin/bash,  I could not understand it, through cpp,

I suggest you take a look at this wikipedia page: Shebang (Unix).
The "#!" announces the script can be executed and its contents will be passed to the executable given and interpreted.

C++ (cpp) is a compiled language. As #! is for interpreted files only (aka scripts), it is most likely you're not dealing with C++ but with a simple shell script.
newbie
Activity: 37
Merit: 0
June 03, 2018, 04:08:31 PM
#1
what is this #!/bin/bash,  I could not understand it, through cpp,
Jump to: