Running Commands on the Files You Find

You can also use find to execute a command you specify on each found file, by giving the command as an argument to the `−exec' option. If you use the string `'{}'' in the command, this string is replaced with the file name of the current found file when the command executes. Mark the end of the command with the string `';''.




Finding the smallest or the largest files and directories

To list the contents of a directory with the smallest files first, use ls with both the `−S' and `−r' options, which reverses the sorting order of the listing.




Finding Where a Command Is Located

Use which to find the full path name of a tool or application from its base file name; when you give the base file name as an option, which outputs the absolute file name of the command that would have run had you typed it. This is useful when you are not sure whether or not a particular command is installed on the system.




Changing File Modification Time

Use touch to change a file's timestamp without modifying its contents. Give the name of the file to be changed as an argument. The default action is to change the timestamp to the current time.




Splitting a File into Smaller Ones

It's sometimes necessary to split one file into a number of smaller ones. For example, suppose you have a very large sound file in the near−CD−quality MPEG2, level 3 ("MP3") format. Your file, `large.mp3', is 4,394,422 bytes in size, and you want to transfer it from your desktop to your laptop, but your laptop and desktop are not connected on a network−−the only way to transfer files between them is by floppy disk. Because this file is much too large to fit on one floppy, you use split.




How to find differences between files

Use diff to compare two files and output a difference report (sometimes called a "diff") containing the text that differs between two files. The difference report is formatted so that other tools can use it to make a file identical to the one it was compared with. To compare two files and output a difference report, give their names as arguments to diff.




Creating a File Archive

To create an archive with tar, use the `−c' ("create") option, and specify the name of the archive file to create with the `−f' option. It's common practice to use a name with a `.tar' extension, such as `my−backup.tar'.




Extracting Files from an Archive

To extract (or unpack) the contents of a tar archive, use tar with the `−x' ("extract") option. · To extract the contents of an archive called `project.tar', type: $ tar −xvf project.tar RET




Tracking Revisions to a File

The Revision Control System (RCS) is a set of tools for managing multiple revisions of a single file.




Checking In a File Revision

When you have a version of a file that you want to keep track of, use ci to check in that file with RCS. Type ci followed by the name of a file to deposit that file into the RCS repository. If the file has never before been checked in, ci prompts for a description to use for that file; each subsequent time the file is checked in, ci prompts for text to include in the file's revision log. Log messages may contain more than one line of text; type a period (`.') on a line by itself to end the entry.




prev [1] [2] [3] [4] [5] [6] [7] [8] next
Items 41 - 50 of 73 displayed.

Back to Home page