#!
chmod [augo]+x -f
Control Flow
$ bash ./f # run file "f" in a subshell
$ bash -c <command> # run <command> in a subshell
$ ./f # execute file "f"
$ which <command> # where is <command> in path on filesystem
$ locate <string> # find all instances of <string> on filesystem
$ find <location> -type d # find a directory
$ find <location> -name <regular expression> # find by name
$ find / -name lab3.txt # find file named "lab3.txt" in /
You can search with regular expressions
$ file <file> # get file type, examples:
$ file ch1.lisp
ch1.lisp: Lisp/Scheme program, ASCII text
$ file ch5.py
ch5.py: Python script, ASCII text executable
$ date
Mon Oct 1 13:22:55 PDT 2018
$ date +<format> # date in <format>
$ date +%A
Monday
$ DAY_OF_WEEK = $(date +%A)
$ echo $DAY_OF_WEEK
Monday
#!/bin/bash
if [[ boolean ]]; then
echo "true"
else
echo "false"
fi #end if
#!/bin/bash # ShaBang for Bash Script
DAY_OF_WEEK=$(date +%A) # set var to output of date command eg "Monday"
if [[ "$DAY_OF_WEEK" == "Monday" ]];
then
echo "It is Monday my dudes."
echo "Today you have CIT160!"
else
echo "It is not Monday my dudes."
echo "Better do your CIT labs!"
fi