Unix file system use different file types1, with each file type indicated by a single character:
character | file type |
---|---|
- | regular files |
b | block-based device files (block devices) |
c | character-based device files (character devices) |
d | directories |
p | named pipes (FIFOs) |
l | symbolic links |
s | sockets |
This is also the first character on each line in the long listing generated by the command ls -l or in the third column generated by the commando find when using the action -ls.
Complete the following Unix command so that it generates an overview on stdout of the number of files under the directory /dev per file type. In this overview the file types must be listed in descending order of the number of found files of that type. If there are file types having the same number of files, they must be listed in alphabetic order.
$ find /dev ! -name "mqueue" -ls | … 7 c 6 l 3 d
The part of the command that has been given (the find command) also finds the hidden files under the specified directory.
Use the cut command to select specific parts of a line. Two important options are -f and -d. The first option indicates that each line must be split into fields, so that the command cut can work with these fields instead of individual characters. By default, the tab character is used as a field separator. However, the option -d can be used to specify an alternative field separator.
Find out what the commands tr, sort and uniq can be used for.
Only submit the part of the command that replaces the tree dots (…).