Bash Script Basic

Creating and running a bash script step by step:

  • (Open your text editor)
  • In the editor, add your commands line by line!
echo "number of lines in file:"

wc -l some_data.csv

echo "number of characters in file:"

wc -c some_data.csv
  • Still in the editor, add this line to the very beginning of your bash script:

#!/usr/bin/env bash 
(This line is called the shebang. It tells Ubuntu that your script is in bash.) 

  • Click "10 Quit" in the bottom right corner of the editor and save your file. 
  • Name your file to (or whatever you prefer)! 
  • Give permission to yourself to run your script. Type this command :
chmod 700
  • Run your script by typing this on the command line:


After running the script, your output will be something like this:

number of lines in file:
number of characters in file:

You can create various bash scripts (even hundreds of lines long) and even Python or SQL scripts the same way.