This is some output from a run of my shell program. Note the jobs
run in the background, the history command, and the !num
commands.
$ ./cs31shell
cs31shell> ls
Makefile cs31shell output sample_out sleeper.c
README.adoc cs31shell.c parsecmd.h sleeper
cs31shell> ls -l -a
total 80
drwx------ 2 newhall users 4096 Oct 27 21:39 .
drwx------ 3 newhall users 4096 Oct 27 20:53 ..
-rw------- 1 newhall users 342 Oct 27 20:54 Makefile
-rw------- 1 newhall users 1163 Oct 27 20:54 README.adoc
-rwx------ 1 newhall users 26824 Oct 27 20:54 cs31shell
-rw------- 1 newhall users 2693 Oct 27 20:54 cs31shell.c
-rw------- 1 newhall users 3165 Oct 27 21:09 output
-rw------- 1 newhall users 1567 Oct 27 20:54 parsecmd.h
-rw------- 1 newhall users 0 Oct 27 21:39 sample_out
-rwx------ 1 newhall users 17448 Oct 27 20:54 sleeper
-rw------- 1 newhall users 644 Oct 27 20:54 sleeper.c
cs31shell> ./sleeper & # run in background
cs31shell> ps
PID TTY TIME CMD
1582424 pts/3 00:00:00 bash
1582455 pts/3 00:00:00 cs31shell
1582524 pts/3 00:00:00 sleeper # child running in background
1582539 pts/3 00:00:00 ps
cs31shell> ./sleeper &
cs31shell> ./sleeper &
cs31shell> ./sleeper &
cs31shell> ps --forest
PID TTY TIME CMD
1582424 pts/3 00:00:00 bash
1582455 pts/3 00:00:00 \_ cs31shell
1582646 pts/3 00:00:00 \_ sleeper # child running in background
1582659 pts/3 00:00:00 \_ sleeper # child running in background
1582669 pts/3 00:00:00 \_ sleeper # child running in background
1582682 pts/3 00:00:00 \_ ps
cs31shell> history # history built-in command
0 ls
1 ls -l -a
2 ./sleeper &
3 ps
4 ./sleeper &
5 ./sleeper &
6 ./sleeper &
7 ps --forest
8 history
cs31shell> history
0 ls
1 ls -l -a
2 ./sleeper &
3 ps
4 ./sleeper &
5 ./sleeper &
6 ./sleeper &
7 ps --forest
8 history
9 history
cs31shell> whoami
newhall
cs31shell> ps --forest
PID TTY TIME CMD
1582424 pts/3 00:00:00 bash
1582455 pts/3 00:00:00 \_ cs31shell
1582805 pts/3 00:00:00 \_ ps
cs31shell> history
3 ps
4 ./sleeper &
5 ./sleeper &
6 ./sleeper &
7 ps --forest
8 history
9 history
10 whoami
11 ps --forest
12 history
cs31shell> cd # cd built-in command
cs31shell> pwd
/home/newhall
cs31shell> cd public/week01
cd: Cannot change directory: No such file or directory
cs31shell> cd public/cs31/week01
cs31shell> ls
Makefile README firstprog.c firstprog_nocomments.c printtypes.c
cs31shell> pwd
/home/newhall/public/cs31/week01
cs31shell> history
10 whoami
11 ps --forest
12 history
13 cd
14 pwd
15 cd public/week01
16 cd public/cs31/week01
17 ls
18 pwd
19 history
cs31shell> cd /usr/include
cs31shell> pwd
/usr/include
cs31shell> ls
EGL gtk-unix-print-2.0 pwd.h
...
gtk-3.0 pulse zstd_errors.h
cs31shell> cd
cs31shell> pwd
/home/newhall
cs31shell> history
16 cd public/cs31/week01
17 ls
18 pwd
19 history
20 cd /usr/include
21 pwd
22 ls
23 cd
24 pwd
25 history
cs31shell> ps --forest
PID TTY TIME CMD
1582424 pts/3 00:00:00 bash
1582455 pts/3 00:00:00 \_ cs31shell
1583237 pts/3 00:00:00 \_ ps
cs31shell> exit # exit built-in command
bye bye