CMD List

来源:互联网 发布:华为云 阿里云 分析 编辑:程序博客网 时间:2024/05/21 08:46

cmd.xls

 

1.1         alias

 

Create an alias for a command or shows which aliases exist. v.s. unalias.

 

Syntax             alias [name = [“command”]]

 

Option or argument

Function

Name

Specifies the alias name.

Command

Specifies the command the name should be an alias for.

 

Sample:

 

Type alias d=’ls –l’, you have just created a new command, d, which is the same as ls –l. To see which aliases you have defined, just type alias.

alias dir='ls -tFg |more'

 

 

1.2         aclget

show access control (AIX), similar with getfacl in solaris. (ls –l just show base information)

 

1.3         basename

Syntax: basename pathname [suffix].

Return filename only.

e.g.

basename /u/dee/desktop/cns.boo cns.boo result: cns.boo

basename /u/dee/desktop/cns.boo .boo result: cns

sh_name=`basename $0 | cut -f1 -d'.'`

 

1.4         bc

Precition.

Option or argument

Function

-l

Set the scale variable to 20.

 

Sample:

echo "9/2" | bc

4

echo "9.5/2" | bc

4

echo "9/2" | bc -l

4.50000000000000000000

echo "9.5/2" | bc -l

4.75000000000000000000

 

1.5         cat

 

Displays a file on-screen. stop at the bottom of file. Relate: more.

 

Syntax             cat filename

 

Option or argument

Function

-n

Add line number.

 

Sample:

 

Type >cat bonus.plan

 

You can also use the cat command (which stands for catenate) to combine two or more files, like this:

 

cat file1 file2 file3 > one.big.file

cat test.sh test.sh test.sh | wc

 

1.6         cd

 

Changes the current working directory to the directory you indicate.

 

To move back to your home directory, type cd without any arguments.

 

To move to a directory that is not a subdirectory of the current working directory, you can use a full pathname – one that begins with a slash. For example, to look around in the /home directory (where all home directories are stored on some systems), type >cd /home

 

If you want to move to the last directory you were in, type >cd -.

 

Syntax             cd [directory]

 

Option or argument

Function

directory

Specifies the directory you want to move to. This directory becomes your current working directory. If you don’t use this option, you move to your home directory.

 

Sample:

You log in and do some work in your home directory. Next you want to move into your budget directory to see which files are there. Type cd budget.

 

Type cd .. to move back up to the parent directory of budget. Sometime you might want to go up to more than one level of the parent directory, type “cd ../..”, you can go back up two levels of parent directory.

 

Type cd to move back default path (check default path via echo $HOME).

 

1.7         chgrp

Changes the group ownership of a file or directory.

chgrp [parameter] Group {File | Directory}

 

1.8         chmod

 

Changes the permissions for a file/directory. You have to own the file or directory to use this command.

 

If you leave the who letter out of the permission, chmod assigns the permission to everyone.

 

Refer to any detail, see Section 2.3.2 of this document.

Syntax             chmod [-Rcfv] [-recursive] [-changes] [-silent] [-quiet] [verbose]

 

permission - drwxrwxrwx

d       - directory

x       - can use the file name as an argument in a command

first rwx    - for owner

second rwx      - for group

third rwx   - for other (except the group)

 

r = 4, w = 2, x = 1.

e.g.

chmod 744 /hsbc/bcn/load/cmb_ocpr_pl_mh_conv1.id   = -rwxr--r—

 

ls -l | awk '{if($1=="-rw-r-----") print $9}' | xargs chmod 644

Change mode in a batch.

 

1.9         chown

Changes the owner or group associated with a file.

Chown [parameter] Owner [:Group] {File | Directory }

 

1.10     clear

 

Clears the screen. This command does not affect files or jobs – it just clears the clutter from your screen.

 

Syntax             clear

 

1.11     cmp

compare 2 binary files. Refer diff.

1.12     cp

 

Copies files/directory. Unlike in DOS, if you want to copy a file to current directory, you have to use a period (.) at the end of the command like, such as “cp file101”.

 

Syntax             cp [-i] oldfiles newfiles

         cp [-i] [-R] oldfiles directory[/newfiles]

 

Option or argument

Function

-i

Asks before you replace an existing file with a copied file.

-r

Copies file hierarchies under the file or directory specified by the SourceFile or SourceDirectory parameter (recursive copy).

-R

When you copy a directory, also copies its subdirectories and creates new subdirectories as necessary.

-f

Specifies removal of the target file if it cannot be opened for write operations.

-h

Forces the cp command to copy symbolic links.

-p

Duplicates characteristics like time, permission, user /group ID.

oldfiles

Specifies the name of the file you want to copy.

newfiles

Specifies the name to give to the new copy.

directory

Specifies the name of the directory in which you want to store a copy.

 

Sample:

 

Type cp /home/harold/margys.feb.expenses february.expenses

 

By including both a path and a filename to copy to, you tell cp to copy the file from the /home/harold/ directory and to name the new copy february.expenses.

 

cp -Rph /hsbc/bsg/databak/. /hsbc/bsg/data

 

1.13     ctmfw

ctmfw FILE(absolute path)

      < mode (CREATE|DELETE)>  Default: CREATE

      < minimum detected size <number>

        [' '|Bytes(B)|Kilo(K)|Mega(M)|Giga(G)] >Default:0

      < interval between file search (seconds) > Default: 60sec

      < interval between filesize comparison iterations (seconds) > Default: 10sec

      < number of iterations while the size is static >  Default: 3 iterations

      < time limit for the process (minutes).>  Default: 0 (no time limit)

        Effective while the file does not exists or,

        the file size is static and the minimum size

        was not reached >

      <  monitor file size , minimal and maximal age, when wildcard is used > Default: N

      < starting  time for detecting files (HHMM or YYYYMMDDHHMM > Default: NOW

      < absolute stop time (HHMM or YYYYMMDDHHMM > Default: +0000 ( No stop time )

      < minimal age of file (modified time)

        format:xxxxYxxxxMxxxxDxxxxHxxxxMin  > Default: NO_MIN_AGE 

      < maximal age of file ( timestamp monitoring )

        format:xxxxYxxxxMxxxxDxxxxHxxxxMin  > Default: NO_MAX_AGE

 

e.g. ctmfw /hsbc/wsd/indata/qwin/pdb2/tbbstxdh.ok CREATE 0 300 10 30 60)

1.14     cut

Option or argument

Function

-d Character

specify delimiter. Default tab. E.g. cut -f1 -d'.'

-f List

e.g. -f 1,7  writes out only the first and seventh fields of each line. If a line contains no field delimiters, passes them.

 

1.15     date

%H   Displays the hour (24-hour clock) as a decimal number (00-23).

%M  Displays the minutes as a decimal number (00-59).

%Y   Displays the four-digit year as a decimal number.

e.g. date +%H%M

 

1.16     df

 

Check available disk space.

 

Syntax             df [-k] [directory]

         df [-t] [-x] [-k] [-p] [-a] ... [filename]

 

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.17     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.18     du

Check disk space usage.

Syntax      du [-a] [-b] [-c] [-D] [-k] [-l] [-L] [-s] [-S] [-x] [filename]

 

1.19     echo

e.g.

echo $HOME

 

1.20     egrep

Searches a file for a pattern.

e.g.

egrep "/(([A-z]+|[0-9]+)/)" my.txt

 

1.21     exec

Refer &.

 

1.22     expr

Compute.

e.g.

Asterisk & Parentheses

expr /( 11 + 5 /) '*' 2

 

1.23     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.24     finger

 

Lists the people using your computer – with their real names, not just their UNIX usernames.

 

Syntax             finger [username]

  or

         finger [@hostname]

  or

         finger [username@hostname]

 

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.25     ftp

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

1.26     get

ftp to local host, refer put.

 

1.27     getfacl (solaris)

show access control, similar with aclget in AIX.

 

1.28     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[Separator]

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 “^[a-zA-Z]” pgm.s

 

Regular Express: grep -E "MatnJobQ|UserJob"

 

find ./ -type f -name "*axmh*" | xargs grep -il "a2mh"

ls -l | grep ^d

1.29     gunzip

 

Restores a gzipped file to its normal size. The gunzip command also restores files compressed with compress or pack.

 

Syntax             gunzip [-c] [-f] [-r] [-v]  filenames

 

Option or argument

Function

-c

Sends the uncompressed file to standard output (usually the screen) instead of to a new file; the original file is unchanged. (This is the same as using zcat.)

-f

Forces uncompression, even if a file with the same name already exists.

-h

help

-r

Recursive; If any of the file names are directories, gunzip descends into the directory (and any of its subdirectories) and uncompresses all the files it finds there.

-S

use suffix .xxx on compressed files

-v

Verbose; displays how much each file is being expanded.

filenames

Specifies the gzipped files to uncompress.

 

Sample:

 

If you want to see what’s in the compressed file facts, type:

 

gunzip -h

gunzip –c facts

gunzip -S .zip ctp_bsct006_01_datadict.txt.zip

 

1.30     gzip

 

Compresses one or more files into one gzipped file so that it takes up less space on your disk. The compressed file has the same name as the original, but with the suffix .gz attached. When your want to get your original files back, you use gunzip or gzip –d.

 

Syntax             gunzip [-c] [-d] [-f] [-l] [-r] [-v]  filenames

 

Option or argument

Function

-c

Sends the gzipped file to standard output (usually the screen) instead of to a new file; the original file is unchanged.

-d

Decompresses; the same as using gunzip.

-f

Forces compression, even if a gzipped file already exists.

-h

help

-l

Displays how much the gzipped file(s) shrank.

-r

Recursive; If any of the file names are directories, gzip descends into the directory (and any of its subdirectories) and compresses all the files it finds there.

-S

use suffix .xxx on compressed files

-v

Verbose; displays how much each file is being shrunk.

filenames

Specifies the file(s) to compress.

 

Sample:

 

You have created a series of very large files and have put them inside a directory called My_Big_Files. Now you want to save all these files in a compressed format to save space. Type

 

gzip -h

gzip –rv My_Big_Files

gzip -S .zip ctp_bsct006_01_datadict.txt (normally use this one. If "gzip -S .zip xxx.txt" in AIX, can’t unzip the file in windows or MF.)

 

 

原创粉丝点击