(base) bash-5.2$ cd sh (base) bash-5.2$ XXXX /home/accts/sbs5/cs201/www/fall_2023/lectures/sh (base) bash-5.2$ XXXX py0 py14 py18 py7 sh1 sh7 users.info py1 py15 py2 py8 sh2 sh8 x py10 py16 py3 py9 sh3 sleep.txt py11 py17 py4 racket.sh sh4 typescript py12 py17.py py5 script sh5 user_data.xml py13 py17.pyc py6 script2 sh6 user.info (base) bash-5.2$ cat script date last | grep $USER | tail (base) bash-5.2$ XXXX bash: source: /usr/bin/script: cannot execute binary file (base) bash-5.2$ XXXX Wed Dec 6 10:52:23 AM EST 2023 sbs5 pts/0 10.66.80.3 Wed Dec 6 10:27 still logged in sbs5 pts/2 10.66.3.39 Wed Dec 6 09:19 still logged in sbs5 pts/1 10.66.3.39 Wed Dec 6 09:14 still logged in sbs5 pts/0 172.26.249.126 Mon Dec 4 10:28 - 11:27 (00:59) sbs5 pts/3 73.253.232.3 Sat Dec 2 18:24 - 08:05 (1+13:41) sbs5 pts/0 10.66.80.3 Fri Dec 1 10:22 - 11:22 (01:00) (base) bash-5.2$ XXXX source is a shell builtin (base) bash-5.2$ XXXX Wed Dec 6 10:52:52 AM EST 2023 sbs5 pts/0 10.66.80.3 Wed Dec 6 10:27 still logged in sbs5 pts/2 10.66.3.39 Wed Dec 6 09:19 still logged in sbs5 pts/1 10.66.3.39 Wed Dec 6 09:14 still logged in sbs5 pts/0 172.26.249.126 Mon Dec 4 10:28 - 11:27 (00:59) sbs5 pts/3 73.253.232.3 Sat Dec 2 18:24 - 08:05 (1+13:41) sbs5 pts/0 10.66.80.3 Fri Dec 1 10:22 - 11:22 (01:00) (base) bash-5.2$ XXXX -rwxrwxr-x 1 sbs5 cs201ta 30 Jul 2 13:47 script -rwxr-xr-x 1 sbs5 cs201ta 12 Jul 2 13:47 script2 (base) bash-5.2$ XXXX Wed Dec 6 10:53:24 AM EST 2023 sbs5 pts/0 10.66.80.3 Wed Dec 6 10:27 still logged in sbs5 pts/2 10.66.3.39 Wed Dec 6 09:19 still logged in sbs5 pts/1 10.66.3.39 Wed Dec 6 09:14 still logged in sbs5 pts/0 172.26.249.126 Mon Dec 4 10:28 - 11:27 (00:59) sbs5 pts/3 73.253.232.3 Sat Dec 2 18:24 - 08:05 (1+13:41) sbs5 pts/0 10.66.80.3 Fri Dec 1 10:22 - 11:22 (01:00) (base) bash-5.2$ cat script2 date whoami (base) bash-5.2$ XXXX Wed Dec 6 10:53:53 AM EST 2023 sbs5 (base) bash-5.2$ XXXX Wed Dec 6 10:54:02 AM EST 2023 sbs5 (base) bash-5.2$ ./sc C-c C-c (base) bash-5.2$ XXXX Wed Dec 6 10:54:20 AM EST 2023 sbs5 (base) bash-5.2$ XXXX hello world (base) bash-5.2$ cat file hello world (base) bash-5.2$ XXXX bash: source: /usr/bin/file: cannot execute binary file (base) bash-5.2$ XXXX bash: hello: command not found bash: world: command not found (base) bash-5.2$ XXXX file: ASCII text (base) bash-5.2$ XXXX script2: ASCII text (base) bash-5.2$ XXXX bash: hello: command not found bash: world: command not found (base) bash-5.2$ XXXX which: no script2 in (/usr/bin:/usr/lib64/qt-3.3/bin:/usr/condabin:/usr/lib64/ccache:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/var/lib/snapd/snap/bin) (base) bash-5.2$ XXXX Wed Dec 6 10:56:40 AM EST 2023 sbs5 (base) bash-5.2$ cat sh1 #! /usr/bin/bash echo 'This is a shell script.' echo ls echo $(ls) (base) bash-5.2$ XXXX This is a shell script. ls file py0 py1 py10 py11 py12 py13 py14 py15 py16 py17 py17.py py17.pyc py18 py2 py3 py4 py5 py6 py7 py8 py9 racket.sh script script2 sh1 sh2 sh3 sh4 sh5 sh6 sh7 sh8 sleep.txt typescript user_data.xml user.info users.info x (base) bash-5.2$ cat sh2 #! /usr/bin/bash ## define function and use local to shadow environment variable echo 'This is a shell script with a function' HELLO=Hello function hello { local HELLO=World echo $HELLO } echo $HELLO hello echo $HELLO (base) bash-5.2$ XXXX This is a shell script with a function Hello World Hello (base) bash-5.2$ cat sh3 #! /usr/bin/bash ## if statement echo 'This is a shell script with an if statement' ME=$(whoami) if [ $ME = 'sbs5' ]; then echo 'hello Professor Slade!' else echo hello $ME fi (base) bash-5.2$ XXXX This is a shell script with an if statement hello Professor Slade! (base) bash-5.2$ cat py0 #! /usr/bin/python3 print ("This is a Python shell script.") (base) bash-5.2$ XXXX This is a Python shell script. (base) bash-5.2$ cat py1 #! /usr/bin/env python3 ## the env command has several uses. print ("This is a Python shell script using env in shebang.") (base) bash-5.2$ XXXX file py12 py17 py3 py8 sh1 sh6 user_data.xml py0 py13 py17.py py4 py9 sh2 sh7 user.info py1 py14 py17.pyc py5 racket.sh sh3 sh8 users.info py10 py15 py18 py6 script sh4 sleep.txt x py11 py16 py2 py7 script2 sh5 typescript (base) bash-5.2$ cat racket.sh #! /usr/bin/racket #lang racket (+ 9 9) (base) bash-5.2$ XXXX 18 (base) bash-5.2$ XXXX alias bestnode='printf '\''ssh sbs5@%s.cs.yale.edu\n'\'' $(tail -q -n 1 /home/usage/*.csv |cut -d, -f 2,7 |tr '\'','\'' '\'' '\'' |sort -n -k 2 |grep -v gari |head -n 1 | tr -sc a-zA-Z '\''\n'\'') ' alias busynodes='printf '\''%15s : %s\n'\'' $(tail -q -n 1 /home/usage/*.csv |cut -d, -f 2,7 |tr '\'','\'' '\'' '\'' |sort -r -n -k 2 |grep -v gari |head -n 15)' alias decode='tr '\''A-Za-z'\'' '\''N-ZA-Mn-za-m'\''' alias emcs='emacs' alias encode='tr '\''A-Za-z'\'' '\''N-ZA-Mn-za-m'\''' alias ens='enscript -2 -r -G' alias idlenodes='printf '\''%15s : %s\n'\'' $(tail -q -n 1 /home/usage/*.csv |cut -d, -f 2,7 |tr '\'','\'' '\'' '\'' |sort -n -k 2 |grep -v gari |head -n 15)' alias la='ls -al' alias lisp='sbcl' alias ll='ls -l' alias mroe='more' alias p='python3' alias p34='python3.4' alias rm='rm -i' alias sbcl='/home/accts/sbs5/bin/sbcl' (base) bash-5.2$ XXXX 1031 cat sh3 1032 ./sh3 1033 cat py0 1034 ./py0 1035 cat py1 1036 ls 1037 cat racket.sh 1038 ./racket.sh 1039 alias 1040 history 10 (base) bash-5.2$ XXXX history 10 1031 cat sh3 1032 ./sh3 1033 cat py0 1034 ./py0 1035 cat py1 1036 ls 1037 cat racket.sh 1038 ./racket.sh 1039 alias 1040 history 10 (base) bash-5.2$ XXXX history 10 1031 cat sh3 1032 ./sh3 1033 cat py0 1034 ./py0 1035 cat py1 1036 ls 1037 cat racket.sh 1038 ./racket.sh 1039 alias 1040 history 10 (base) bash-5.2$ XXXX alias alias bestnode='printf '\''ssh sbs5@%s.cs.yale.edu\n'\'' $(tail -q -n 1 /home/usage/*.csv |cut -d, -f 2,7 |tr '\'','\'' '\'' '\'' |sort -n -k 2 |grep -v gari |head -n 1 | tr -sc a-zA-Z '\''\n'\'') ' alias busynodes='printf '\''%15s : %s\n'\'' $(tail -q -n 1 /home/usage/*.csv |cut -d, -f 2,7 |tr '\'','\'' '\'' '\'' |sort -r -n -k 2 |grep -v gari |head -n 15)' alias decode='tr '\''A-Za-z'\'' '\''N-ZA-Mn-za-m'\''' alias emcs='emacs' alias encode='tr '\''A-Za-z'\'' '\''N-ZA-Mn-za-m'\''' alias ens='enscript -2 -r -G' alias idlenodes='printf '\''%15s : %s\n'\'' $(tail -q -n 1 /home/usage/*.csv |cut -d, -f 2,7 |tr '\'','\'' '\'' '\'' |sort -n -k 2 |grep -v gari |head -n 15)' alias la='ls -al' alias lisp='sbcl' alias ll='ls -l' alias mroe='more' alias p='python3' alias p34='python3.4' alias rm='rm -i' alias sbcl='/home/accts/sbs5/bin/sbcl' (base) bash-5.2$ XXXX 1033 cat py0 1034 ./py0 1035 cat py1 1036 ls 1037 cat racket.sh 1038 ./racket.sh 1039 alias 1040 history 10 1041 alias 1042 history 10 (base) bash-5.2$ XXXX cat racket.sh #! /usr/bin/racket #lang racket (+ 9 9) (base) bash-5.2$ XXXX PID TTY TIME CMD 3711650 pts/3 00:00:00 bash 3724704 pts/3 00:00:00 ps (base) bash-5.2$ XXXX ps is hashed (/usr/bin/ps) (base) bash-5.2$ XXXX PID TTY TIME CMD 3711650 pts/3 00:00:00 bash 3724926 pts/3 00:00:00 ps (base) bash-5.2$ sleep (base) bash-5.2$ XXXX [1] 3725701 (base) bash-5.2$ XXXX PID TTY TIME CMD 3711650 pts/3 00:00:00 bash 3725701 pts/3 00:00:00 sleep 3725882 pts/3 00:00:00 ps (base) bash-5.2$ XXXX [1]+ Running sleep 2000 & (base) bash-5.2$ XXXX [2] 3726040 (base) bash-5.2$ XXXX [1]- Running sleep 2000 & [2]+ Running sleep 1000 & (base) bash-5.2$ XXXX [1]- Terminated sleep 2000 (base) bash-5.2$ XXXX PID TTY TIME CMD 3711650 pts/3 00:00:00 bash 3726040 pts/3 00:00:00 sleep 3726249 pts/3 00:00:00 ps (base) bash-5.2$ XXXX [2]+ Running sleep 1000 & (base) bash-5.2$ XXXX (base) bash-5.2$ XXXX PID TTY TIME CMD 3711650 pts/3 00:00:00 bash 3726591 pts/3 00:00:00 ps [2]+ Terminated sleep 1000 (base) bash-5.2$ XXXX PID TTY TIME CMD 3711650 pts/3 00:00:00 bash 3726775 pts/3 00:00:00 ps (base) bash-5.2$ XXXX fg is a shell builtin (base) bash-5.2$ XXXX kill is a shell builtin (base) bash-5.2$ XXXX jobs is a shell builtin