|
|
|||
CREATING MORE THAN ONE SUBDIRECTORY AT A TIME Here's a directory-creating trick that's often forgotten even by those of us who have recourse to the command prompt daily. Suppose you already have a directory called ~/documents (a directory called "documents" that is located within your home directory, symbolized by the tilde). You want to create the following directory: ~/documents/articles/may-01 However, the ~/documents/articles subdirectory doesn't exist. If you aren't aware of this trick, you'll use the mkdir command twice (once to make ~/documents/articles and again to make ~/documents/articles/may- 01). But that's not necessary, thanks to the -p option. If you include this option, mkdir automatically creates parent directories as needed. The following command creates the ~/documents/articles directory as well as ~/documents/articles/may-01: mkdir -p ~/documents/articles/may-01 QUICK REFERENCE TO DIRECTORY LISTING TRICKS Here's a tip to print and keep near your Linux system! The GNU versions of the standard Linux directory listing commands (dir and ls) provide many command options that can help you pinpoint the file you're looking for. Here are some of the most useful: *ls -Sl lists files sorted by size, showing the largest files first. * ls -Shl lists files sorted by size, showing the largest files first, and shows sizes in human-readable form. * ls -tl lists files sorted by time of last modification, showing the most recently modified files first. * ls -Rtlr *.xpm uses reverse chronological order (oldest files first) and lists all the files in the current directory (and all associated subdirectories) that have the *.xpm extension. *ls -F displays filenames with appended characters that indicate the file type, such as executable (*) or directory (/). In the GNU versions of the basic file utilities provided with most Linux distributions, the dir and ls commands are identical, so you can freely substitute dir for ls in the above examples. |
||||