Summary of the linux Tips recently used

Source: Internet
Author: User
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 //...



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.



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


: % S/^ M/g


^ M is input by pressing ctrl + v, ctrl + m.



Bash is being compared

-Ne,-eq,-le,-lt,-ge, and-gt are all used for numerical size comparison.


= ,! =: These are used for string comparison.



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.



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'


Echo $ I



#! /Bin/bash

For I in $ (seq 1 5)


Echo $ I




] # Sed-n'/keyword/{n; p }'

The next line of the output keyword


] # Grep-A 2 keyword

The next two lines of the output keyword



Write a simple version of cluster server management

This script runs normally after the trust relationship is established


#! /Bin/bash



#] #./ root server-list.txt "ls-l/home"


If [$ #-ne 3]


Echo "Usage: $0 "

Exit 1



For server_list in $ (cat $2)


Ssh $1 @ $ server_list $3


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.