Bash scripts

Open the terminal.

mkdir bash-scripts
cd bash-scripts
nano script1.sh  //open nano, and write this:
#!/bin/bash   //tells the system to use the bash program
echo here's my script //then Ctrl-X to exit nano.
chmod 755 script1.sh //make the file executable
./script1.sh //runs the script
nano script1.sh //open file and add more to the script:
//exit and run at any stage
echo Please enter your name
read NAME //stores user input in variable called NAME
echo "Hi $NAME!" //gets this variable by using $ //exit
echo //puts in a blank line
var1=Hello //sets a variable; note no spaces
var2=Person
echo $var1 $var2 //calls these variables
mydir=./R_files //the variable is that directory
echo $mydir
ls $mydir //lists the files in that directory
echo $1 $2 //these are cmd line args 1 and 2, entered after ./script
var4=$(ls) //var4 is the output of that command
echo The files in this directory are: $var4