textboy 发表于 2013-1-14 07:12:57

CMD List [2]

1.1         df

 
Check available disk space.
 
Syntax             df [-k] [directory]
         df [-t] [-x] [-k] [-p] [-a] ...
 

Option or argument
Function
-g
Displays statistics in units of GB blocks
-k
Displays only the amount of free space in kilobytes.
-v
Displays all information for the specified file system.
Directory
Displays space on the file system where that directory resides.
 
The df listing includes lots of information about each file system (logical disk or disk partition) to which you have access, including its total size, the amount of space that’s full (used), the free space, the percentage that’s full (capacity), and, if it’s a network file system, on which file server it is.
 
Sample:
 
You are wondering how much space is on the disk on which your home directory is stored. Assuming that your username is ysg, type
 
df /home/ysg
 
e.g. fr wing: df –gv|grep bcn; df -gv ./; df –h ./ (for solaris)
1.2         diff

 
Compares two files and prints the lines in which the files differ, for ascII files. Refer cmp.
 
Syntax             diff [-b] [-i][-w] filename1 filename2
  or
         diff [-b] [-i][-w] filename1 directory1
  or
         diff [-b] [-i][-r][-w] directory1 directory2
 

Option or argument
Function
-b
Treats groups of spaces (blanks) as single spaces, so it ignores spacing differences.
-i
Ignores the difference between uppercase and lowercase letters.
-r
When you’re comparing two directories, specifies that subdirectories should be compared, too.
-w
Ignores all spaces and tabs.
filename1
Specifies one file to compare.
filename2
Specifies the other file to compare.
directory1
Specifies one directory to compare. If you tell diff to compare a file to a directory, it looks in the directory for a file of the same name and compares the two files
directory2
Specifies the other directory to compare. If you tell diff to compare two directories, it looks in both directories for files of the same name and compares all pairs of files with the same names. It also lists the names of files that are in one directory but not in the other.
 
1.3         du

Check disk space usage.
Syntax      du [-a] [-b] [-c] [-D] [-k] [-l] [-L] [-s] [-S] [-x]
 
1.4         echo

e.g.
echo $HOME
 
1.5         egrep

Searches a file for a pattern.
e.g.
egrep "\((+|+)\)" my.txt
 
1.6         exec

Refer &.
 
1.7         expr

Compute.
e.g.
Asterisk & Parentheses
expr \( 11 + 5 \) '*' 2
 
1.8         find

 
Finds one or more files based on rules your give, and does something to them.refer whereis.
 
Syntax             find directory [-name filename] [-user username] [-print]
 

Option or argument
Function
directory
Specifies a list of directories in which you want to begin the search. The find command searches all the subdirectories of these directories, too. If you want to start in the current directory, just type a single period(.).
-name filename
Specifies the name of the file (or files) you want to find. If you don’t know the exact name, you can use the wildcard characters ? and *.A? stands for any single character, and a * stands for a group of characters. You must quote the filename if you use wildcards.
-user username
Specifies the user who owns the files you want to find.
-print
Displays the names of files it finds. If you don’t include this option, the find command may find lots of files, but it doesn’t tell you about them.
-type f
Check if plain file, vice versa ‘–type d’ check if directory
 
 
Sample:
 
If you want to look in several places for a file, you can type several directories on the command line, like this:
 
find . /home/john –name chapter3 -print
The . (dot) tells the find command to search the current directory and its subdirectories.
 
To search for all the files you own (assuming that your username is stuart), type
 
find / -user stuart -print
The / (slash) tells the find command to search the root directory and all of its subdirectories.
 
find /hsbc/rlse_bcn/objects -type f | xargs rm
Delete all the files in this folder
find /hsbc/rlse_bcn/objects -type f -exec rm
the problem with this approach is that each time find matches a file, it invokes rm, which is a very resource-intensive strategy.
 
find ./ -type f -name "*axmh*"
find ./ -type d -name "folder"
 
1.9         finger

 
Lists the people using your computer – with their real names, not just their UNIX usernames.
 
Syntax             finger [username]
  or
         finger [@hostname]
  or
         finger
 

Option or argument
Function
username
Specifies the user (or users) about whom you want more information.
hostname
Specifies the hostname of the computer about which you want information.
See also who.
 
Sample:
 
You wonder who else is using your computer. Type:
 
finger
 
To find more information about a user andrewg, type
 
finger andrewg
 
1.10     ftp

use like in DOS. Can use command like lcd / cd / put / get.
1.11     get

ftp to local host, refer put.
 
1.12     getfacl (solaris)

show access control, similar with aclget in AIX.
 
1.13     grep

 
Finds lines in one or more files that contain a particular word or phrase.
To prevent regular expressions is interpreted as wildcards, it is better to surround the regular expression with single quotes ( ' ).
Complex expression try egrep.
Search for multiple patterns at once try fgrep.
 
Syntax             grep [-i] [-l] [-n] [-v] text  filenames
 

Option or argument
Function
-E
-E flag is the same as the egrep command, except that error and usage messages are different and the -s flag functions differently.
-i
Ignores case (uppercase and lowercase) when you’re searching.
-l
Displays only the names of the files that contain the text, not the actual lines.
-n
Displays the line numbers that contain the text.
-p
Displays the entire paragraph containing matched lines. Paragraphs are delimited by paragraph separators.
-s
Display only error message for checking.
-v
Specifies that you’re looking for lines that don’t contain the text.
text
Specifies the word or phrase to search for. If the text includes spaces or punctuation that may confuse AIX, enclose it in quotation marks.
filenames
Specifies the file(s) in which to search; to search all the files in the current directory, type * (asterisk).
 
e.g.
 
You are looking for the memo you wrote in which you mentioned microwaveable shelf-stable foods. To search all the files in the current directory, type:
 
grep “mentioned microwaveable shelf-stable” *
 
if you don’t find the file you want. You realize that the M might be capitalized, so you tell grep to ignore capitalization by typing:
 
grep –i “mentioned microwaveable shelf-stable” *
grep -n IBISCMB *.sql
 
grep -B1 -A1 "tty" /etc/passwd
display the context.
 
grep “^” pgm.s
 
Regular Express: grep -E "MatnJobQ|UserJob"
 
find ./ -type f -name "*axmh*" | xargs grep -il "a2mh"
ls -l | grep ^d
 
页: [1]
查看完整版本: CMD List [2]