Skip to content

Instantly share code, notes, and snippets.

@shiveshabhishek
Last active April 3, 2018 02:52
Show Gist options
  • Save shiveshabhishek/bd9995cdf12f52d2d9800e99c5b96eff to your computer and use it in GitHub Desktop.
Save shiveshabhishek/bd9995cdf12f52d2d9800e99c5b96eff to your computer and use it in GitHub Desktop.

Give exec permission to your script:

chmod +x /path/to/script.sh

Now, run your script

/path/to/script

or

./script.sh

(the above command when your are in the directory of the script file)


Checking file permission

ls -l filename.extension

where r represents read permission. w represents write permission and x represents executable permission.

For furhter elaborations, [Click Here] (https://askubuntu.com/questions/528411/how-do-you-view-file-permissions)

Storing a script output inside a file via bash script

echo `whoami` > /path/to/file (this will overwrite)

echo `ls` >> /path/to/file (this will append )

Make sure to add !#/bin/bash in the beginning of your bash script

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment