wc [ -lwc ] [ filename ... ]You can have any combination of options.
larry% ls
hi mp.and.the.holy.grail.txt
larry% wc mp.and.the.holy.grail.txt
1417 10380 60531 mp.and.the.holy.grail.txt
larry% wc -l mp.and.the.holy.grail.txt
1417 mp.and.the.holy.grail.txt
larry% wc -w mp.and.the.holy.grail.txt
10380 mp.and.the.holy.grail.txt
larry% wc -c mp.and.the.holy.grail.txt
60531 mp.and.the.holy.grail.txt
larry% wc -cwl mp.and.the.holy.grail.txt
60531 10380 1417 mp.and.the.holy.grail.txt
larry%
head [ -n ] [ filename ...]head displays the first n lines of each filename. If -n is not specified, it defaults to 10.
larry% ls
hi mp.and.the.holy.grail.txt
larry% head hi
Hi there. How are you?
larry% head mp.and.the.holy.grail.txt
"The Script, of The Soundtrack, of The Movie, of the Python Presentation, of
The Retelling of the Great Classic, of The Myth, of The Legend, of The
Unproven Hearsay, of The See Webster's Dictionary for the Definiton of the
Above - Better Known as...
(Alias) (Wik) *(Da Duh Da Daaaaaa)*
MONTY PYTHON AND THE MOST HOLY GRAIL
(and we really mean it)
(also also wik)
larry% head -2 mp.and.the.holy.grail.txt
"The Script, of The Soundtrack, of The Movie, of the Python Presentation, of
larry%
tail [ +|-n ] [ filename ]Tail will display the last 10 lines of the file unless there is a +n or -n. If there is a +n, tail displays all of the lines after the nth line. If it is a -n, tail displays the last n lines.
larry% ls
hi mp.and.the.holy.grail.txt
larry% tail mp.and.the.holy.grail.txt
(Alias) (Also also also wik) *(Da Duh Da Daaaaaa.)*
MONTY PYTHON AND THE MOST HOLY GRAIL
(and we really mean it)
(Why not try a holiday in Sweden this year)
(See many large furry animals)
(Including the majestic Moose)
(No, really! My sister got bitten by a moose once. AAAAGH!)
(The Management would like to apologize and say:)
(1: The previous writer of the parenthesis has been sacked.)
(2: THE END)
larry% tail -2 mp.and.the.holy.grail.txt
(1: The previous writer of the parenthesis has been sacked.)
(2: THE END)
larry% wc -l mp.and.the.holy.grail.txt
1417 mp.and.the.holy.grail.txt
larry% tail +1412 mp.and.the.holy.grail.txt
(See many large furry animals)
(Including the majestic Moose)
(No, really! My sister got bitten by a moose once. AAAAGH!)
(The Management would like to apologize and say:)
(1: The previous writer of the parenthesis has been sacked.)
(2: THE END)
larry%
sort [-d, -f, -n, -o filename, -r ] [ filename ... ]Sort takes it's input from standard input unless a file or filenames are specified. It then sorts the file by line, and returns it to standard output, usually the screen. The different options cause sort to sort the data in different ways.
The "-d" option sorts the file in a "dictionary" way. Only characters, numbers and black space are used to determine the order.
The "-f" causes sort to sort in a case insensitive manner.
An "-n" option causes sort to sort in a numerical fashion.
An "-o" option causes sort to write to a file specified after the option instead of to the screen.
Finally, a "-r" option sorts in reverse order.
larry% cat breakfast toast eggs rock pancake Cereal cereal killer mushroom milk orange juice sun syrup bomb larry% sort breakfast Cereal bomb cereal killer eggs milk mushroom orange juice pancake rock sun syrup toast larry% sort -f breakfast bomb Cereal cereal killer eggs milk mushroom orange juice pancake rock sun syrup toast larry% sort -r breakfast toast syrup sun rock pancake orange juice mushroom milk eggs cereal killer bomb Cereal larry%
larry% ls -l total 86 -rwxr-xr-x 1 schallee 24576 Jul 13 09:54 a.out -rw-r--r-- 1 schallee 87 Jul 13 09:38 breakfast -rw-r--r-- 1 schallee 23 Jul 11 15:51 hi -rw-r--r-- 1 schallee 60531 Jul 11 15:51 mp.and.the.holy.grail.txt larry%The first field of every line is the file permissions. The file permissions consist of sets of thee characters. If there is a "-" instead of the right character, that permission is denied.
The first character is the read permission. It will have a "r" if it is granted.
Next comes the write permission. This decides if a user can change the file. If it is a "w" then the user can change the file.
The last permission is the execute permission. This decides if a user can execute the file. This is usually only set on files that are programs. The character for it is "x".
The first of these three groups, starting with the second character of the line, is the permissions for the owner of the file. The second is for the members of the group the file belongs to, and the third is the permissions for everyone else.
To set the permissions of a file, you use the chmod command.
chmod ugo,+-,rwx filenames ...The first option determines what permissions you are giving the following files. First comes which group of people you are dealing with. "u" for the owner, you, "g" for the members of the group, and "o" for everyone else. Then a plus sign if you are adding permissions, or a minus sign if you are subtracting permissions. Then what permissions in the form of "r" for read, "w" for write, and "x" for execute.
So, if I want to let anyone add items to my list of breakfast items, I would give everyone in my group and everyone else, write permission to the file:
larry% ls -l breakfast -rw-r--r-- 1 schallee 87 Jul 13 09:38 breakfast larry% chmod g+w breakfast larry% chmod o+w breakfast larry% ls -l breakfast -rw-rw-rw- 1 schallee 87 Jul 13 09:38 breakfast larry%And if I wanted to deny execute permission to "a.out" to every one except those in my group and myself, I would:
larry% ls -l a.out -rwxr-xr-x 1 schallee 24576 Jul 13 09:54 a.out larry% chmod o-x a.out larry% ls -l a.out -rwxr-xr-- 1 schallee 24576 Jul 13 09:54 a.out larry%
larry% wc mp.and.the.holy.grail.txt
larry% head -20 mp.and.the.holy.grail.txt
larry% tail -20 mp.and.the.holy.grail.txt
larry% sort -f breakfast
larry% sort -r -o lunch breakfast
larry% chmod g+w lunch larry% chmod o+w lunch
larry% ls -l lunch