Command and replace vim

cat
View the contents of a file
-n view the file line number
cat / etc / hosts / / etc / passwd> all.txt file merge
cat merge files, you can use statistical work
more
view the file contents
f down page by page view content spaces
b up to view the contents page by page
note turn the last page automatically exit
less
page by page view file contents important common
-N display line numbers
f down page by page
b to page by page on
/ search file contents Oh
n find the next content
N find on a content
and fast same vim of
gg first line
G end of line
q to quit
view large files with less viewing
head
displays the first 10 lines of the key elements file default
number of lines -n display content short head - 4 show the first four lines of
the case: the maximum virtual memory usage
ps axu | awk '{print $ 5}' | sort -rn | head -1
first few characters of text -c interception of head -c5 first 5 characters

tail
displays the contents of the file after the end of the default 10-line focus
-n Number of lines to display short tail -5 show the last 5 lines
-f view the text real-time updates of content shorthand tailf file (speed tail -f will hurry)
-F - -follow --retry content in real-time output file if the file does not currently exist will be retried until the file exists
grep
to filter out content that we need to find the file Musketeers youngest
-v Invert
case: Finding did not bring under / etc / selinux / config No. content #
grep -v '#' / etc / SELinux / config
-n find the content display line numbers
first written
grep 'content' high-efficiency file
a second written
cat file
grep 'content' (if using a grep command statistics came out to the front of the filter, can only use the pipe)
grep to find out the content highlighted
tr
replace the contents of a file (tr character is replaced by one of the characters)
- remove d
tr -d [az] <oldboy.txt remove all letters az
TR ":" "#" </ etc / the passwd
\ n-carriage
vim Advanced Alternatively
: s # root # oldboy # cursor line replacement of a root
: all root s # root # oldboy # g cursor line is replaced Oldboy
:% root # S # G # Oldboy replace all root document appears to Oldboy br /> ###
///
@@@
^ beginning
;
command separator regardless of whether the previous command fails, fail: the next command
&&
previous command was successful will be performed && behind the command
In front of the command does not execute Behind the command

Special symbols

输出重定向 先清空在写入

Appending redirection appends the end of the file
<input redirection TR <File CAT
1> output the correct standard abbreviations>
2> standard error
1 >>
2 >>
in three stages Shell programming
of correct and incorrect results were redirects to different files
ls oldboy.txt> output ok.txt correct results to a file
ls oldboy.txt 2> output ok.txt erroneous results to a file
lss >> ok.txt 2 >> ok.txt right and wrong output to a file
ls / tmp / >> ok.txt 2 >> ok.txt right and wrong output to a file
lss &> ok.txt right and wrong output to a file

常用的书写方式
2>&1   &>file

Guess you like

Origin blog.51cto.com/14465325/2428209
Recommended