Linux Utilities | Part 1
The cpio provides three functions:
- Creates an archive from a list of files(-o option)
- Extracting some or all files in an archive (-i option)
- Copying files from one directory to another, recreating the original directory structure at the destination
/bin/ls | cpio -ocBv > /dev/fd0
archives the current directory and its subdirectories onto device fd0
find:
- -name file :- True if the current file matches >file
- -user uname :- True if the owner of the current file is user user
- -group gname :- True if the current file belongs to group group_name
- -links n :- True if the curent file has 'n' links
- -size n :- True if the current file is 'n' units long
- -atime n :- True if the current file ahs been accessed n days ago
- -mtime n :- True if tehc urrent file has been modified n days ago
- -ctime n :- True if the i-node information of the current file has been modified n days ago
- -local :- TRue if the current file resides on the local system rather than on a remote system
- -inum :- True if teh current file starts with i-node inum
Applying commands to files:
- -exec cmd
find crud -name "*.bak" -type f -exec rm {} \;
The above command removes all files matching "*.bak" in the directory crud and its subdirectories- Be user that the '{}' and ';' appear as separate arguments to find after the shell quotation has been removed
Tests executed for their side effects:
The following tests are always true and are executed only for the sake of their side effects- -print :- Always true; as a side-effect, sends the pathname of the current line to standard output
- For Example:-
find . -user bin
will produce those files in or below the current directory belonging to user bin - But the command
find . -print -user bin
will produce all files in the current directory no matter whom they belong to since -print will be tested before -user - -cpio file
- Always true; but gives an error if the file cannot be written to. As a side effect, adds the current file toa cpio-formatted archive in archive
- -depth
- Always true; as a side-effect, causes find to process the entries ihna directory before the entries in a directory before processing the directory itself when edescending the directory hierarchy
Examples:
find /usr /lib -name "*.1"
- List all files anywhere in /usr or /lob whose names end in ".1";
find ~ /dev/mt0 -mtime -8 -cpio
- Copy all files within your own directories taht have been modified in the last week to the device /dev/mt0 in cpio fiormat
find hold backup -type f \( -size +10 -o -links +1 \) -exec rm {} \;
- Remove all regular files within the directorieshold and backup that atre larger tahn 10 blocks(5120 bytes) or having another link somewhere
find hold backup -name antema -prune -o -print
- List all files withij the directories hold and backup, skipping any that are within a subdirectory(at any level) named anatema
find ~/tmp ! -user -user naomi -type d -print
- List all the subdirectories of the directory ~/tmp that do not belong to you(assuming your name is naomi)
The cksum program calculates the checksums of one or more files. The algorithm is the usual one for cyclic redundancy check (CRC) error checcking
The checksum provides a n integrity check ona partivcuar file and is partuvularly usefule when the file is transmitted over a network.cksum [file ...]
Terminals duffer in their features and the control sequences they sue to represent a file. To account for tghese differences, Lunux programs consult the termcap and terminfo database when they issue or interpret a terminal -depenedent control sequences
terminfo contains three types of items:
- Boolean capabilities, which indicate whether or not the terminal supports some particular feature
- Numeric capabilities, which indicate the size of the terminal or the limits on particular features
- String capabilitites, which indicate what control sequence must be sent to the terminal to achieve a particular effect
You can use the uuencode program to encode a binary file into a sequence of lines, each of a convienient length and each consisting entirely of printable ASCII characters.
The uudecode cpmmand the the opposite of uuencodeThe wc command is often used in conjunction with other commands,as a way of counting items in alist
who | wc -l
Tee command example:
soundoff | tee transcript | hearken
The standard output of soundoff becomes the standard input of heaken and is also recorded in the file "transcript"The "mv" and "cp" commands
The "rm" and "rmdir" commands
Comments
Post a Comment