DOC PREVIEW
FSU COP 4342 - File Management

This preview shows page 1-2-24-25 out of 25 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

File managementgzip and gunziptarfinddf and duodsftp and scpUnix Tools: Program Development 6gzip and gunzipgzip compresses the files named on the command line. Aftercompressing them, it renames them with .gz suffixes.General form:gzip [FILE]*gunzip undoes compression created by gzip.General form:unzip [FILE]*Other programs that have been used for compression: compact,compress, and zip/unzip.You can also use gzip/gunzip as filters with the -c option,which redirects output to stdout.Finally, you can specify the level of compression; -1 gives thefastest compression but does not optimize space, and -9 givesthe slowest compression but the best use of space.Unix Tools: Program Development 6tartar is an old utility, and literally stands for “Tape Archiver”. Thesedays, it is used far more often to handle file archives. It is very usefulfor creating transportable files between systems, such as when youwant to mail a group of files to someone else.Unix Tools: Program Development 6tar options-c # create an archive-x # extract from an archive-t # shows files in an archive-f # specify a file (the default is a tape device!). You can# specify stdout with ‘‘-’’ (or use -O)-C # change directory-v # work verbosely-z # use gzip/gunzip; if used with -c, creates a gzip’d file; if used# with -x or -t, it uses gunzip to read the existing archive file-p # preserve permissions when extractingUnix Tools: Program Development 6Using tarTypically, you will do something like this to create a tar archive ofan existing subdirectory:tar cf DIRNAME.tar [DIRNAME]+tar czf DIRNAME.tar.gz [DIRNAME]+tar -c -f DIRNAME.tar [DIRNAME]+tar -c -z -f DIRNAME.tgz [DIRNAME]+Unix Tools: Program Development 6Using tarTypically, you will do something like this to extract an tar archive ofan existing subdirectory:tar xf DIRNAME.tartar xzf DIRNAME.tar.gztar -x -f DIRNAME.tartar -x -z -f DIRNAME.tgzUnix Tools: Program Development 6findOne of the most useful tools with a recondite syntax is find. Itallows you to search a directory for files matching some subset of alarge number of possible criteria.find [PATH]+ CRITERIAUnix Tools: Program Development 6find criteria-name FILENAME # finds files which match FILENAME, which can contain# wildcards-iname FILENAME # same as -name, but also case-insensitive-size [+/-]N[bck] # very useful, it finds files by size. using ’b’ (or nothing)# indicates N is in blocks; using ’c’ indicates N is in bytes;# using ’k’ indicates N using kilobytes. Using ’+’ means that# the file is greater than N in size; using ’-’ means# that it is less than N in size; using neither means# the file is exactly size N.-mtime [+/-]N # find files based on their last modification time, and N is# in days. +N means match files that have been modified in more# than N days; -N means match files that have been modified in# less than N days; N means match files that have been modified# exactly N days previous.-ls # show files in {\tt ls} format rather than just the filename-printf # lets you specify arbitrary output formats-exec COMMAND ; # lets you run COMMAND over every matching file-okay COMMAND ; # same as -exec, but queries you for confirmation before executing# the commandUnix Tools: Program Development 6find logical operatorsCRIT1 -a CRIT2 # match only if both criteria CRIT1 and CRIT2 holdCRIT1 -o CRIT2 # match if either criteria CRIT1 or CRIT2 holds!CRIT1 # match if criterion CRIT1 does not hold\( EXPR \) # evaluate EXPR earlyUnix Tools: Program Development 6find examplesfind . # walk the current directory and its subdirectoriesfind /tmp -mtime +6 # find all files in /tmp that have not been# modified in 6 daysfind /tmp -name core -exec rm {} \; # remove files named ’core’ from /tmpfind /tmp -name core -o name ’*.o’ -okay rm {} \;# query to remove files that are named ’core’ or end in ’.o’find /tmp -iname ’*.sh’ -exec chmod +x {} \;# add execute permission to all files that end in ’.sh’,# ’.SH’, ’.Sh’, or ’.sH’Unix Tools: Program Development 6df and duThe df command displays information about mounted filesystems. Ifyou don’t specify any, then all of the mounted filesystems are shown.You don’t have to specify mount points; any file inside of a filesystemis acceptable:[2006-Fall]$ dfFilesystem 1K-blocks Used Available Use% Mounted on/dev/hda2 75766204 19014760 52902672 27% //dev/hda1 101089 40221 55649 42% /bootnone 251668 0 251668 0% /dev/shm/dev/sda1 981192 480508 450840 52% /mnt-tmp[2006-Fall]$ df /boot/boot.bFilesystem 1K-blocks Used Available Use% Mounted on/dev/hda1 101089 40221 55649 42% /bootUnix Tools: Program Development 6df and duThe du command shows you the usage of disk space. With nooptions, it walks your current directory and shows you the space inblocks used by each subdirectory. With -s, it just shows you asummary. You can force du to display in 1k blocks with the -koption.[2006-Fall]$ du -sk .8744 .[2006-Fall]$ du midterm180 midterm1/Questions/Shell20 midterm1/Questions/Process52 midterm1/Questions/Perl20 midterm1/Questions/Emacs20 midterm1/Questions/Awk20 midterm1/Questions/General980 midterm1/Questions1636 midterm1Unix Tools: Program Development 6odThe od (octal dump) program writes representations of files to stdout.If ’-’ is specified, then it looks to stdin for input.For example, the default od output for the current pdf file is:[langley@sophie 2006-Fall]$ od 22-filemanagement.pdf0000000 050045 043104 030455 031456 032412 030040 067440 0651420000020 036012 020074 051457 027440 067507 067524 027440 0201040000040 033133 030040 051040 020040 043057 072151 056440 0370400000060 005076 067145 067544 065142 034412 030040 067440 0651420000100 036040 005074 046057 067145 072147 020150 030465 0200640000120 020040 020040 020040 027412 064506 072154 071145 027440...Unix Tools: Program Development 6od and xxdod is useful in several ways; for instance, you can find controlcharacters embedded in files that an editor might not display in areasonable fashion (though emacs is pretty good at displayingembedded characters.)Unix Tools: Program Development 6Using od[2006-Fall]$ od -a 22-filemanagement.pdf0000000 % P D F - 1 . 3 nl 5 sp 0 sp o b j0000020 nl < < sp / S sp / G o T o sp / D sp0000040 [ 6 sp 0 sp R sp sp / F i t sp ] sp >0000060 > nl e n d o b j nl 9 sp 0 sp o b j0000100 sp < < nl / L e n g t h sp 5 1 4 sp0000120 sp sp sp sp sp sp nl / F i l t e r sp /....Unix Tools: Program Development 6Using od[2006-Fall]$ od -c


View Full Document

FSU COP 4342 - File Management

Download File Management
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view File Management and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view File Management 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?