Omar Ramos Thoughts of a Webmaster

Home Tips & How-tos Plesk Description of the tar and find command options

Description of the tar and find command options

E-mail Print PDF

tar options (and their meanings):

# (extract archive contents)
-x 
--extract 

# (list archive contents) 
-t
--list 

# (make new tar archive)
-c
--create 

# (specify name of archive file)
-f
--file 

# (show the files being worked on as the tar is being performed)
-v
--verbose 

find options:

# (for greater than n)
+n
# (for less than n)
-n
# (for exactly n)
n 
# (last modified n minutes ago)
-mmin n 
# (last modified n*24 hours ago)
-mtime n
# (pattern represents a filename string to look for, may also contain special regular expression characters)
-name pattern
# (replace c with a d, for directory or f, for a regular file)
-type c 
# (allows you to execute commands on every file found by the find command, very useful. You can use the special token {} which represents the current filename)
-exec 
# (tells the find command how many folder levels to recurse through, use a 1 to only pick up files from the current directory)
-maxdepth n

Examples of using the find command

# returns all files matching the pattern created in the last 14 days
find -name 'var1*' -mtime -14

# returns all files over 14 days old
find -name 'var1*' -mtime +14

# finds all files matching the pattern and then executes the rm -R command on the file
# the final \ is necessary when using the -exec option because it signifies the end of the command you are trying to execute
find -name '_vti_cnf' -type d -exec rm -R {} \;
Last Updated ( Saturday, 31 January 2009 18:52 )  
0 Votes

0 Comments

Add Comment


    • >:o
    • :-[
    • :'(
    • :-(
    • :-D
    • :-*
    • :-)
    • :P
    • :\
    • 8-)
    • ;-)