Task 4 [Section 2: Running Commands] – Manual Pages and Flags
Most of the commands you’ll learn about have a lot of options that are not immediately known at first glance, these options are known as flags, and have the format <command> <flag> <input>
. These flags can be learned about using the man
command. The man command has the format man <command>
. Therefore, to learn about flags for the echo command, we would type man echo
. Typing that shows us a nicely formatted document:
We get alot of information, but the flags are stored in the description section. For example the flag to remove the newline is -n. So to output “Shiba
” without the newline you would type echo -n Shiba
.
Note: Some commands support the -h flag, meaning you can type <command> -h
and get a list of flags and other useful information without using man
.
Task 5 [Section 3: Basic File Operations] – ls
ls is a command that lists information about every file/directory in the directory. Just running the ls command outputs the name of every file in the directory.
As with other commands ls has many flags that can manipulate the output. For example ls -a
shows all files/directories including ones that start with .
Task 6 [Section 3: Basic File Operations] – cat
cat short for concatenate, does exactly that, it outputs the contents of files to the console. For example, given a file called a.txt which contains the data “hello”, cat a.txt
would output hello.
Note: cat supports the –help flag meaning that you can see useful flags without going to the man page!
0 Comments