Notes for Computer Information Technology 160
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long. 1.5KB

October 1

  • #!
  • chmod [augo]+x -f

  • Control Flow

    • If
    • While (until)
    • For ()
    • For () in ()

Files and Commands

$ 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 Commands

$ 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 Command

$ file <file> # get file type, examples:

$ file ch1.lisp
ch1.lisp: Lisp/Scheme program, ASCII text

$ file Python script, ASCII text executable

Date Command

$ date
Mon Oct  1 13:22:55 PDT 2018

$ date +<format> # date in <format>

$ date +%A

$ DAY_OF_WEEK = $(date +%A)

$ echo $DAY_OF_WEEK

If Statement

if [[ boolean ]]; then
  echo "true"
  echo "false"
fi #end if

If Statement with Date Command

#!/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" ]];
  echo "It is Monday my dudes."
  echo "Today you have CIT160!"
  echo "It is not Monday my dudes."
  echo "Better do your CIT labs!"