1. use sed to insert a line break] # sed & amp; #39; s /\(. \) {n \}/\ n/g & amp; #39; in file, the n in braces indicates inserting a line break 2 after the n character. the windows line break ^ M. use the built-in replacement function of vi to delete the following esc input: % s/^ M //...
1.
Use sed to insert line breaks
] # Sed's/\ (. \) {n \}/\ n/g' file
N in braces indicates that a line break is inserted after n characters.
2.
If you view a windows file under vi, the windows line break ^ M will appear. you can delete the file by using the replacement feature provided by vi.
Click esc
Input
: % S/^ M/g
^ M is input by pressing ctrl + v, ctrl + m.
3.
Bash is being compared
-Ne,-eq,-le,-lt,-ge, and-gt are all used for numerical size comparison.
While
= ,! =: These are used for string comparison.
4.
Reference shell variables in awk
I think the best way is
] # From_shell = "hi awk"
] # Awk '{print' "$ from_shell" '}'
This makes it difficult to have other problems.
5.
In scripts or other places, sometimes the result of some commands must be assigned to the variable value.
You can use ''or $ ()
For example
#! /Bin/bash
For I in 'seq 1 5'
Do
Echo $ I
Done
Or
#! /Bin/bash
For I in $ (seq 1 5)
Do
Echo $ I
Done
6.
] # Sed-n'/keyword/{n; p }'
The next line of the output keyword
] # Grep-A 2 keyword
The next two lines of the output keyword
7.
Write a simple version of cluster server management
This script runs normally after the trust relationship is established
#! /Bin/bash
########
# C-ssh.sh
#] #./C-ssh.sh root server-list.txt "ls-l/home"
########
If [$ #-ne 3]
Then
Echo "Usage: $0 "
Exit 1
Fi
For server_list in $ (cat $2)
Do
Ssh $1 @ $ server_list $3
Done