In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Basic syntax of tr
-c # replaces this character set with a complement to the character set in string 1, requiring the character set to be ASCII
-d # Delete all input characters in string 1
-s # removes all recurring character sequences, leaving only the first one: compressing the recurring string into a single string
A string of characters in [amurz] # amerz
A string of characters in [Amurz] # Amurz
[0-9] # numeric string
\ octal # A three-digit octal number that corresponds to a valid ASCII character
[Olymn] # indicates that the character O is repeated a specified number of times n. So [Olympian 2] matches the string of OO
Expression of specific control characters in tr\ a Ctrl-G\ 007 # ringtone
\ b Ctrl-H\ 010 # backspace character
\ f Ctrl-L\ 014 # go to change pages
\ n Ctrl-J\ 012 # New Line
\ r Ctrl-M\ 015 # enter
\ t Ctrl-I\ 011 # tab key
\ v Ctrl-X\ 030 tr Amurz Amurz # convert all uppercase to lowercase letters
Tr "\ n" # replace spaces with line breaks
Tr-s "[012]"
< plan.txt # 删除空行 tr -s ["\n"] < plan.txt # 删除空行 tr -s "[\015]" "[\n]" < file # 删除文件中的^M,并代之以换行 tr -s "[\r]" "[\n]" < file # 删除文件中的^M,并代之以换行 tr -s "[:]" "[\011]" < /etc/passwd # 替换passwd文件中所有冒号,代之以tab键 tr -s "[:]" "[\t]" < /etc/passwd # 替换passwd文件中所有冒号,代之以tab键 echo $PATH | tr ":" "\n" # 增加显示路径可读性 1,$!tr -d '\t' # tr在vi内使用,在tr前加处理行范围和感叹号('$'表示最后一行) tr "\r" "\n" unixfile # Mac ->UNIX
Tr "\ n"\ r" macfile # UNIX-> Mac
Tr-d "\ r" unixfile # DOS-> UNIX Microsoft DOS/Windows convention, each line of text ends with a carriage return character (\ r) followed by a newline character (\ n)
Awk'{print $0 "\ r"} 'dosfile # UNIX-> DOS: in this case, awk is required because tr cannot insert two characters to replace a character #! / bin/sh # in the first line of the script, the script header # sh is the current system default shell, and can be specified as shell such as bash
Sh-x # execution process
Sh-n # check syntax
(a=bbk) # parentheses create a child shell to run
Basename $0 # remove the path and extension from the file name
Dirname # fetch path
$RANDOM # Random number
$# process number
Source FileName # reads and executes commands in FileName in the current bash environment. FileName
Sleep 5 # sleep interval of 5 seconds
Trap # actions to be taken after receiving the signal
Trap "" 2 3 # prohibit ctrl+c
$PWD # current directory
$HOME # Home Directory
$OLDPWD # the path to the previous directory
Cd-# returns the previous directory path
Yes # repeat Printing
Yes | rm-I * # automatically answer y or other
Ls-p / home # View all folders in the directory
Ls-d / home/ # View the full path of the match
Echo-n aa;echo bb # execute the next sentence without line wrapping
Echo-e "s\ tss\ n\ n\ n" # to make the escape effective
Echo $a | cut-c2-6 # fetch characters in a string
Echo {a _ parenthetical _ c _ c} {_ (one element in parentheses is combined with other parentheses respectively)
Echo $((2x11010)) # binary to decimal
Echo aaa | tee file # overwrite the file while printing by default-an append
Echo {1... 10} # prints 10 characters
Printf's\ n' | tr "" a # prints 10 characters
Pwd | awk-F /'{print $2}'# returns the directory name
Tac file | sed 1P 3D | tac # read the file upside down # Delete the last three lines
Tail-3 file # take the last three lines
Outtmp=/tmp/$$ `date +% s% N`.outtmp # temporary file definition
: () {: |: &};: # the famous fork × ×, the system executes a large number of processes until the system is dead
Echo-e "\ 033 [0bot 31ml\ 033 [0x 32mV\ 033 [0x 33mV\ 033 [0x 34m E\ t\ 033 [0x 35m Y\ 033 [0x 36mU\ 033 [0x 32mU\ e [m" # print color seq syntax] does not specify a starting value, the default is 1
The-s # option mainly changes the output delimiter, and the default is\ n
-w # allelic completion, that is, the width is equal and the insufficient preceding complement is 0.
-f # formatted output, which specifies the format of the print
Seq 10 100 # list 10-100
Seq 1 10 | tac # list backwards
Seq-s'+'90 100 | bc # is added from 90 to 100
Seq-f 'dir%g' 1 10 | xargs mkdir # create dir1-10
Seq-f 'dirg' 1 10 | xargs mkdir # create dir001-010
Sed sed 10q # displays the first 10 lines in the file (simulates "head")
Sed-n'$='# count rows (simulate "wc-l")
Sed-n '5Jing / ^ no/p' # prints all lines from line 5 to lines starting with no
Sed-I "/ ^ $fplash d" a # Delete matching lines
Sed-I'/ aaa/,$d' # Delete the matching line to the end
Sed-I "sCharger" / "c # replace text directly
Sed-I "/ ^ pearls/s/$/j/" # find pearls and add j at the end of the line
Sed'/ 1 file # print lines between 1 and 3
Sed-n '1p' file # fetch the specified line
Sed'5i\ aaa' file # insert a row before line 5
Sed'5a\ aaa' file # enter the line after line 5
Echo a | sed-e'/ a row I\ b'# insert a row before the matching line
Echo a | sed-e'/ a swap a\ b'# insert a row after matching lines
Echo a | sed's _ a _ &\ nb/g' # inserts a row after the matching line
Seq 10 | sed-e {1Magazine 3} s Uniqq.Universe _ _ # matches 1 and 3 line substitution
Sed-n'/ regexpqqqqump' # displays only lines that do not match regular expressions
Sed'/ regexp/d' # displays only lines that do not match regular expressions
Sed'$! Nash /\ nUniverse'# concatenates every two lines into one line
Sed'/ baz/s/foo/bar/g' # replace "foo" with "bar" only if the string "foo" appears on the line
Sed'/ BAZGUAGUBZAGUBAGUR: replace "foo" with "bar", and only if the string "baz" does not appear in the line
Echo a | sed-e's Universe GOOG'# precede a by #
Sed's Placement FooAccord 4'# replaces only the fourth string in each line
Sed's /\ (. *\) foo/\ 1barmap'# replaces the last string on each line
Sed's /\ (. *\) foo\ (. * foo\) /\ 1bar\ 2max'# replace the penultimate string
Sed's / [0-9] [0-9] $/ & 5' # add 5 after the line ending in [0-9] [0-9]
Sed-n'/ ^ eth\ | em [01] [^:] / {nstorp;}'# matches multiple keywords
Sed-n-r'/ eth | em [01] [^:] / {nstorp;}'# matches multiple keywords
Echo-e "1\ N2" | xargs-I-t sed's / ^ / 1max'{} # process multiple files at the same time
Sed'/ west/,/east/s/$/*VACA*/' # modifies all lines between west and east, adding * VACA* at the end
Sed's / [^ 1-9] *\ ([0-9]\ +\). * /\ 1Compact'# takes the first set of numbers and ignores the first 0
Sed-n'/ regexp/ {gtransf 1 match;}; h'# looks for the string and displays the previous line of the matching line, but does not show the matching line
Sed-n'/ regexp/ {ntransp;}'# looks for the string and displays the next line of the matching line, but does not show the matching line
Sed-n's /\ (mar\) got/\ 1iannemp p' # Save\ (mar\) as label 1
Sed-n's /\ ([0-9]\ +\). *\ (t\) /\ 2\ 1Universe p'# saves multiple tags
Sed-I-e '1Magazine 3d'-e's hand 1max 2max'# multiple edits (delete 1-3 lines first, replace 1 with 2)
Remove all characters after @ and blank lines after sed-e's Universe
Sed-n-e "{s / text (regular) / replaced content / p}" # replace and print out the replacement line
Sed-n-e "{s / ^ * [0-9] * / / p}" # print and delete that part of the regular expression
Echo abcd | sed 'y_ matching character substitution
A line substitution character that does not begin with the sign'2 # in sed'/ ^ # / btransact
Sed'/ suan/r read in file'# find the line containing suan and add the contents of the read file to the end
Sed-n'/ no/w write file'# find the line containing no and write to the specified file
Sed'/ regex/G' # inserts a blank line after the matching sample line
Sed'/ regex/ {x _ Tinct _ x _ X _ G;}'# insert a blank line before and after the matching sample line
Sed 'ntrandd' # Delete all even rows
Sed'Gten G' # add two blank lines after each line
Sed'/ ^ $/ dscape G' # there will be only one blank line after each line in the output text
Sed'nposit nttermitntGternThere'# add a blank line after every five lines
Sed-n '5cm 5p' # only prints multiples of line number 5
Seq 1 30 | sed '5cm 5sswap. Replace on a multiple line of "Universe Universe"
Sed-n'3, ${ptinct, n,
Parity exchange of sed-n'htern _ TX _ Gittre
Seq 1 10 | sed'1, Gentleman, leading, holding, listing, flashback
Ls-l | sed-n'/ ^ .rwx. * / p'# find files with primary permissions of 7
Sed = filename | sed'Nsmars /\ n /\ t bank'# number each line in the file (simple left alignment)
Sed's / ^ [\ t] * /'# remove the leading "white space character" (space, tab) of each line and align it to the left
Sed's / ^ [\ t] * / /; s / [\ t] * $/ /'# removes leading and trailing white space characters from each line
Echo abcd\\ nabcde | sed's /\\ nUniverse Universe G' | tr'@'\ n' # convert the newline character to newline
Cat tmp | awk'{print $1}'| sort-n | sed-n'$p'# take the maximum value of a column
Sed-n'{s / ^ [^\ /] * / /; s /\:. * /; p}'/ etc/passwd # fetch the user's home directory (match characters that are not / and match: delete all characters to the end)
Sed = filename | sed'Nsmarts / ^ / /; s / * (.\ {6,\}\)\ n /\ 1 /'# number all lines in the file (line numbers are on the left and text is aligned on the right)
/ sbin/ifconfig | sed 's/.*inet addr:\ (. *\) Bca.*/\ 1Universe g' | sed-n' / eth/ {nbot}'# take all IP modified keepalive configurations and eliminate the backend server sed-I'/ real_server.*10.0.1.158.*8888/,+8 s / ^ / # / 'keepalived.conf
Sed-I'/ real_server.*10.0.1.158.*8888/,+8 s / ^ # / / 'keepalived.conf
Imitate the rev function echo 123 | sed'/\ nUniverse Genders /\ (.\)\ (. *\ n\) / &\ 2\ 1According to the function of Dansi.
/\ nUniverse G; # does not have a newline character, so execute G because the reserved space is empty, so append a blank line in the mode space
S /\ (.\)\ (. *\ n\) / &\ 2\ 1max; # tag replacement &\ n23\ n1 $(the key is &, which can be followed by / / to match to a blank line)
The / / D; # D command causes the first part of the pattern space to be looped out. If there are remaining rows in the pattern space after deletion, the command before D is returned and re-executed. If there is nothing in the mode space after D, it will exit.
/ / D match blank line to execute D, if the previous sentence s does not match, / / can not match to the blank line, "/ / D;" command ends
After the end of # D, delete the beginning\ nawk judgment
Awk'{print ($1 > $2)? "first row" $1: "second row" $2}'# conditional judgment brackets represent if statement judgment "?" For then ":" for else
Awk'{max= ($1 > $2)? $1: $2; print max}'# condition determines that if $1 is greater than $2, the max value is $1, otherwise it is $2
Awk'{if ($6 > 50) print $1 "Too high";\
Else print "Range is OK"} 'file
Awk'{if ($6 > 50) {count++;print $3}\
Else {xylene 5; print $2}} 'file
Awk cycle
Awk'{I = 1; while (I)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.