Script started on Wed Nov 4 17:27:52 2026 Restored session: Mon Nov 2 18:40:18 EST 2026 macbook:Desktop> cat q20.txt We have a list of people in a file as first_name last_name, with no other information, and we want to sort them by last_name, then print them as last_name first_name. Which command below does this? a. awk '{ print $2" "$1 }' < file | sort b. awk -sort $1 $2 | file c. sort $2 $1 < file | awk d. sort $1 $2 < file > awk macbook:Desktop> ps PID TTY TIME CMD 1160 ttys000 0:00.14 -zsh 18420 ttys000 0:00.01 script Nov4_2026.log 1177 ttys001 0:00.66 -zsh 1188 ttys002 0:00.06 -zsh 1212 ttys003 0:00.38 -zsh 28349 ttys004 0:00.03 -zsh 1790 ttys005 0:00.01 zsh 18421 ttys006 0:00.05 /bin/zsh -i macbook:Desktop> echo Hello there Hello there macbook:Desktop> echo -n Hello there Hello there% macbook:Desktop> cd csc3320_Fall2026/programs/C_ch16 macbook:C_ch16> ls *.c zsh: no matches found: *.c macbook:C_ch16> cd ../C_ch17 macbook:C_ch17> ls *.c zsh: no matches found: *.c macbook:C_ch17> ls *.c.txt C_ch17_1.c.txt C_ch17_4.c.txt C_ch17_9.c.txt C_ch17_10_v2.c.txt C_ch17_5.c.txt malloc_ex1.c.txt C_ch17_10.c.txt C_ch17_6.c.txt malloc_ex2.c.txt C_ch17_2.c.txt C_ch17_7.c.txt malloc_ex2b.c.txt C_ch17_3.c.txt C_ch17_8.c.txt macbook:C_ch17> ls C_ch17_?.c.txt C_ch17_1.c.txt C_ch17_3.c.txt C_ch17_5.c.txt C_ch17_7.c.txt C_ch17_9.c.txt C_ch17_2.c.txt C_ch17_4.c.txt C_ch17_6.c.txt C_ch17_8.c.txt macbook:C_ch17> ls C_ch17_[5679].c.txt C_ch17_5.c.txt C_ch17_6.c.txt C_ch17_7.c.txt C_ch17_9.c.txt macbook:C_ch17> echo `ls` C_ch17_1.c.txt C_ch17_10_v2.c.txt C_ch17_10.c.txt C_ch17_2.c.txt C_ch17_3.c.txt C_ch17_4.c.txt C_ch17_5.c.txt C_ch17_6.c.txt C_ch17_7.c.txt C_ch17_8.c.txt C_ch17_9.c.txt malloc_ex1.c.txt malloc_ex2.c.txt malloc_ex2b.c.txt test.txt macbook:C_ch17> V=`ls` macbook:C_ch17> echo $V C_ch17_1.c.txt C_ch17_10_v2.c.txt C_ch17_10.c.txt C_ch17_2.c.txt C_ch17_3.c.txt C_ch17_4.c.txt C_ch17_5.c.txt C_ch17_6.c.txt C_ch17_7.c.txt C_ch17_8.c.txt C_ch17_9.c.txt malloc_ex1.c.txt malloc_ex2.c.txt malloc_ex2b.c.txt test.txt macbook:C_ch17> ls C_ch17_1.c.txt C_ch17_4.c.txt C_ch17_9.c.txt C_ch17_10_v2.c.txt C_ch17_5.c.txt malloc_ex1.c.txt C_ch17_10.c.txt C_ch17_6.c.txt malloc_ex2.c.txt C_ch17_2.c.txt C_ch17_7.c.txt malloc_ex2b.c.txt C_ch17_3.c.txt C_ch17_8.c.txt test.txt macbook:C_ch17> ls | awk '{ print $1 }' C_ch17_1.c.txt C_ch17_10_v2.c.txt C_ch17_10.c.txt C_ch17_2.c.txt C_ch17_3.c.txt C_ch17_4.c.txt C_ch17_5.c.txt C_ch17_6.c.txt C_ch17_7.c.txt C_ch17_8.c.txt C_ch17_9.c.txt malloc_ex1.c.txt malloc_ex2.c.txt malloc_ex2b.c.txt test.txt macbook:C_ch17> ls | wc -l 15 macbook:C_ch17> ls -l malloc_ex1.c.txt| cat malloc_ex1.c.txt #include #include int main() { char *p; p = malloc(10000); if (p == NULL) { printf("Could not allocate memory\n"); exit(0); } printf("Memory allocation worked\n"); free(p); return 0; } macbook:C_ch17> ls -l malloc_ex1.c.txt; cat malloc_ex1.c.txt -rw-r--r-- 1 mweeks staff 232 Sep 12 2025 malloc_ex1.c.txt #include #include int main() { char *p; p = malloc(10000); if (p == NULL) { printf("Could not allocate memory\n"); exit(0); } printf("Memory allocation worked\n"); free(p); return 0; } macbook:C_ch17> gcc malloc_ex1.c.txt -o malloc_ex1 && ./malloc_ex1 ld: unknown file type in 'malloc_ex1.c.txt' clang: error: linker command failed with exit code 1 (use -v to see invocation) macbook:C_ch17> mv malloc_ex1.c.txt malloc_ex1.c macbook:C_ch17> gcc malloc_ex1.c -o malloc_ex1 && ./malloc_ex1 Memory allocation worked macbook:C_ch17> gcc malloc_ex2.c.txt || echo "compilation did not work" ld: unknown file type in 'malloc_ex2.c.txt' clang: error: linker command failed with exit code 1 (use -v to see invocation) compilation did not work macbook:C_ch17> vi sleep_ex.sh macbook:C_ch17> chmod 700 sleep_ex.sh macbook:C_ch17> ./sleep_ex.sh done sleeping macbook:C_ch17> ./sleep_ex.sh & [1] 29434 macbook:C_ch17> echo "I have the prompt back" I have the prompt back macbook:C_ch17> done sleeping [1] + done ./sleep_ex.sh macbook:C_ch17> echo $SHELL /bin/zsh macbook:C_ch17> bash bash-5.3$ # this is a comment bash-5.3$ one="1" bash-5.3$ echo $one 1 bash-5.3$ echo "Filename is \"file1\". " Filename is "file1". bash-5.3$ echo "Filename is \"$one\". " Filename is "1". bash-5.3$ filename="malloc_ex2.c.txt" bash-5.3$ echo $filename malloc_ex2.c.txt bash-5.3$ echo "Filename is \"$filename\". " Filename is "malloc_ex2.c.txt". bash-5.3$ ls [A-Za-z]* C_ch17_1.c.txt C_ch17_5.c.txt malloc_ex1.c C_ch17_10_v2.c.txt C_ch17_6.c.txt malloc_ex2.c.txt C_ch17_10.c.txt C_ch17_7.c.txt malloc_ex2b.c.txt C_ch17_2.c.txt C_ch17_8.c.txt sleep_ex.sh C_ch17_3.c.txt C_ch17_9.c.txt test.txt C_ch17_4.c.txt malloc_ex1 bash-5.3$ date Wed Nov 4 18:27:44 EST 2026 bash-5.3$ echo today is ‘date‘ today is ‘date‘ bash-5.3$ echo today is `date` today is Wed Nov 4 18:29:21 EST 2026 bash-5.3$ echo today is 'date' with single quotes today is date with single quotes bash-5.3$ echo -n hello there hello therebash-5.3$ bash-5.3$ echo '-n hello there' -n hello there bash-5.3$ echo "today is ‘date‘" > example.txt bash-5.3$ xxd example.txt 00000000: 746f 6461 7920 6973 20e2 8098 6461 7465 today is ...date 00000010: e280 980a .... bash-5.3$ cat example.txt today is ‘date‘ bash-5.3$ echo $MAIL bash-5.3$ echo $HOME /Users/mweeks bash-5.3$ echo $USER mweeks bash-5.3$ echo the name of this file is $0 echo the first argument is $1 echo the list of all arguments is $* echo this script places the date into a \ temporary file called $1.$$ date > $1.$$ ls -l $1.$$ rm $1.$$ the name of this file is bash the first argument is the list of all arguments is this script places the date into a temporary file called .29552 -rw-r--r-- 1 mweeks staff 29 Nov 4 18:42 .29552 bash-5.3$ echo '3 * 4 = 12' 3 * 4 = 12 bash-5.3$ echo "3 * 4 = 12" 3 * 4 = 12 bash-5.3$ exit exit macbook:C_ch17> exit Saving session... ...saving history...truncating history files... ...completed. Script done on Wed Nov 4 18:45:46 2026