K-LUG Linux Challenge and Puzzler #1
Challenge (Tina Wood)
'whatis commandname' - a command that returns the header line (and section number) of the manual page for commandname. You can then look up the entirety of the manual page using 'man commandname'. If >1 section is given, specify the section you're interested in looking up using 'man -s sectionnumber commandname'. 'man commandname' - a command that returns the reference manual page for commandname. 'man -a commandname' returns all sections appended together if >1 section exists. 'man -s sectionnumber commandname' allows you to specify the section number you're interested in if >1 section exists. 'xman' allows you to see a list of commands organized by section, and search the man pages for the key word as the command name or in the header line. 'apropos keyword' - a command that returns the command name, section number, and header line of the manual page for every command whose header line contains the keyword. Apropos will find the desired keyword if it is a substring of a larger word in the header line as well. Use these tools to find a command to determine the type of a random file: > whatis file file file (n) - Manipulate file names and attributes file file (1) - determine file type file file (1b) - determine the type of a file by examining its contents file file (1) - determine file type file file (1b) - determine the type of a file by examining its contents > apropos file | grep type | grep determine (excerpt) file file (1) - determine file type file file (1b) - determine the type of a file by examining its contents 'file filename' tests filename to identify its type, including directory, character special, programming language, or empty file. Try it on the files in the tarball: > file mystery_file1 mystery_file1: ELF 32-bit LSB dynamic lib 80386 Version 1, dynamically linked, stripped > file mystery_file2 mystery_file2: ELF 32-bit LSB executable 80386 Version 1, dynamically linked, stripped > file mystery_file3 mystery_file3: ELF 32-bit LSB core file 80386 Version 1, from 'Š' Results: mystery_file1 is an ELF DLL mystery_file2 is an ELF executable mystery_file3 is an ELF core file
Puzzler (Kevin Arhelger)
See file upi.sh.gz. There are a few improvements that could be made... First of all, always write scripts for the Bourne shell unless you need interactive features. Secondly, exit after printing the usage. Finally, although this is not a mistake, it is often more convenient to make your scripts read in from standard input and output to standard output. It's almost always easier to deal with un-named pipes that using the named variety. Other than that, great answer!