A collection of practical Linux operating system skills

Source: Internet
Author: User
Article Title: a collection of practical skills for Linux operating systems. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Because Linux is getting longer and longer, and more things are required, efficiency has become the bottleneck that I must break through. I would like to summarize some of the good Linux skills used during this period. In the future, it will be very convenient to use it as needed.

[Text Processing]

1. View part of a file

If you only want to view the first five lines of the file, you can use the head command,

For example: head-5/etc/passwd

If you want to view the last 10 lines of the file, you can use the tail command,

For example: tail-10/etc/passwd

View the middle part of the file. You can use the sed command

Such as: sed? N'5, 10p'/etc/passwd so that you can only view rows 5th to 10th of the file

2. Change 123 in file.txt to 456.

Method 1

Sed's/123/456/G' file.txt> file.txt. new: Save it to another file.

Sed-I's/123/456/G' file.txt directly modify the original file

Method 2

Vi file.txt

Enter the following command:

: % S/123/456/g

Note: If the replaced file has a special symbol such as/, use \ to cancel it.

Example: sed-I's/\/usr \/local \/apache2 \/htdocs/\/var \/www \/html/G'/usr/local/apache2/conf/ httpd. conf

If you only add the following original row, use &

Example: sed-I's/DirectoryIndex index.html. var/& index.htm index. php/G'/usr/local/apache2/conf/httpd. conf

3. Typical echo applications

Echo "abcdefg" | perl-lne '{$ a = reverse ($ _); print $ a;}' flip a string

Echo bottle | rev flip a string

4. filter out the # header line and all blank lines (useful for viewing configuration documents)

Awk '/^ [^ #]/& amp;/^ [^ $]/' filename> new. file

[1] [2] [3] [4] [5] [6] [7] Next page

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: info-contact@alibabacloud.com 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.