This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
unix_survival [2020/04/08 21:24] joshd |
unix_survival [2020/04/08 23:09] joshd |
||
---|---|---|---|
Line 1: | Line 1: | ||
**UNIX Command Reference** | **UNIX Command Reference** | ||
- | The command prompt in UNIX is called the // | + | The command prompt in UNIX is called the //shell//, which typically uses a dollar sign ($) as its prompt. Here is a list of common UNIX commands which will work across many different versions of UNIX with discrepancies in Example/ |
||Command||Description||Examples||Notes|| | ||Command||Description||Examples||Notes|| | ||
Line 142: | Line 142: | ||
< | < | ||
$ cc table.c | $ cc table.c | ||
- | ./a.out | + | $ ./a.out |
1 x 1 = 1 1 x 2 = 2 1 x 3 = 3 1 x 4 = 4 | 1 x 1 = 1 1 x 2 = 2 1 x 3 = 3 1 x 4 = 4 | ||
2 x 1 = 2 2 x 2 = 4 2 x 3 = 6 2 x 4 = 8 | 2 x 1 = 2 2 x 2 = 4 2 x 3 = 6 2 x 4 = 8 | ||
Line 150: | Line 150: | ||
</ | </ | ||
+ | ** Shell Programming ** | ||
+ | |||
+ | The shell itself is programmable via /shell scripts/ | ||
+ | |||
+ | As with the C examples above, we'll use //ed// to create our source files. | ||
+ | |||
+ | < | ||
+ | $ ed hello.sh | ||
+ | #!/bin/sh | ||
+ | |||
+ | echo " | ||
+ | . | ||
+ | w | ||
+ | 33 | ||
+ | q | ||
+ | $ | ||
+ | </ | ||
+ | |||
+ | The first line (//# | ||
+ | Now we've created the script, and there it is on disk: | ||
+ | |||
+ | < | ||
+ | $ ls -l hello.sh | ||
+ | -rw-rw-rw- | ||
+ | </ | ||
+ | |||
+ | But if we try to run it, we get: | ||
+ | |||
+ | < | ||
+ | $ ./hello.sh | ||
+ | sh: ./hello.sh: Execute permission denied. | ||
+ | </ | ||
+ | |||
+ | (The exact message may vary depending on what UNIX you're on.) This is telling us that the script we created doesn' | ||
+ | |||
+ | < | ||
+ | $ chmod u+x hello.sh | ||
+ | $ ls -l hello.sh | ||
+ | -rwxrw-rw- | ||
+ | $ | ||
+ | </ | ||
+ | |||
+ | As you can see the hello.sh file now has the //execute bit// set (see the " | ||
+ | |||
+ | < | ||
+ | $ ./hello.sh | ||
+ | Hello, world! | ||
+ | $ | ||
+ | </ | ||