Jump to content

Bash scripting: Difference between revisions

From Squishu Wiki
Created page with "== General == * Run a script ** /bin/sh blah.sh * Make executable ** chmod +x blah.sh Run it now that it's executable * ./blah.sh * You could create a bin directory for yourself ** mkdir ~/bin ** Add it to your path *** Edit your .bash_profile *** MAC - edit .zprofile **** vi ~/.zprofile **** Add this line to the end of the file **** export PATH="/Users/bbasura/bin:$PATH" **** Log out and back in **** chmod u+x /Users/bbasura/bin/blah.sh **** cd /Users/bbasura/bin **** R..."
 
No edit summary
 
Line 18: Line 18:
**** cd /Users/bbasura/bin
**** cd /Users/bbasura/bin
**** Run simply with:  blah.sh
**** Run simply with:  blah.sh
== Example Scripts ==
* Simple script with for loop, do loop, and if
** https://github.com/BlancaBasura/bashz/blob/main/blah.sh

Latest revision as of 11:50, 5 July 2025

General

  • Run a script
    • /bin/sh blah.sh
  • Make executable
    • chmod +x blah.sh

Run it now that it's executable

  • ./blah.sh
  • You could create a bin directory for yourself
    • mkdir ~/bin
    • Add it to your path
      • Edit your .bash_profile
      • MAC - edit .zprofile
        • vi ~/.zprofile
        • Add this line to the end of the file
        • export PATH="/Users/bbasura/bin:$PATH"
        • Log out and back in
        • chmod u+x /Users/bbasura/bin/blah.sh
        • cd /Users/bbasura/bin
        • Run simply with: blah.sh

Example Scripts