Linux Common commands

Source: Internet
Author: User

1. Convert lowercase letters to uppercase

echo "ABcD" |tr ' A-Z ' ' A-Z '

2. Uppercase letter Conversion lowercase letters

echo "ABcD" |tr ' A-Z ' ' A-Z '

3. Current Script path

basepath=$ (CD ' DirName $ '; pwd)

For detailed explanations, please see http://www.cnblogs.com/FlyFive/p/3640267.html

4. Common Date Variables

Date + '%y%m%d%h%m%s '

The output format is: 20161027090005

Date + '%y-%m-%d%h:%m:%s '

The output format is: 2016-10-27 09:00:05

5. Sed common commands

Delete the line that matches test

Sed-i '/test/d '/tmp/test.txt

Modify the contents of the/tmp/test.txt test to Test1

Sed-i ' s/test/test1/g '/tmp/test.txt

If you encounter special characters, replace/substitute # or other characters. For example: Sed-i ' s#test#test1#g '/tmp/test.txt

6, Row to column

Execute command: Cat/tmp/test.txt

Output:

A b C

Execute command:

For Parm in $ (cat/tmp/test.txt)

Do

Echo $parm

Done

Output Result:

A

B

C

7. List of career change

Execute command: Cat/tmp/test.txt

Output:

A

B

C

Execute command: cat/tmp/test.txt|xargs-r

Output:

A b C

Linux Common commands

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.