Working with Files
Let me tell you the secret of computers, of operating systems, and of the whole industry that
The
Commands to Know and Love, Part 2
File-Naming Conventions
Valid filenames may contain
almost
any character. You do have to pay some attention to the
Some valid filename examples include the following: fish duck program_2.01 a.out letter.to.mom.who.I.dont.write.often.enough.as.it.is .bash_profile
Notice the last
Listing Files with Emotion!The ls command seems so simple, and yet it has a number of options that can give you tons of information. Change to something like the /etc directory and try these options if you never have: cd /etc ls --color ls -b ls -lS ls -lt
The first listing will show different types of files and directories in color. The second (
-b
) will show octal representations for files that might have been created with control characters. Depending on the terminal you are using, the default is to show question marks or simply blanks. If you need to access (or delete) the file, it helps to know what it is really called. The third and fourth options control sorting. The
-lS
option gives you a long listing (lots of information) sorted by file
|
A Peek at Metacharacters
Metacharacters are special
Extending our talk of listing files, you could list all files containing " ackle " by using this command: $ ls *ackle* hackle hackles tackles Similarly, you could find all the words that start with an " h " like this: $ ls h* hackle hackles Now, if you want to see all the seven-letter words in your directory, use this command: $ ls ??????? hackles tackles Each question mark represents a single letter position. |