Common shell commands

Source: Internet
Author: User

1. Search

GREP-LR YHB./

Indicates that all files in the current directory, including sub-files, are searched for the YHB character, and the file name is printed. If there is no-l, the searched rows will be printed out.

2. Display the number of rows

NL test.txt

The line number of a non-blank line is displayed by default.

Nl-b a Test.txt

Displays the line numbers for all lines, including blank lines.

NL Test.txt | Wc-l

Count Non-empty rows

3.sed command

  • Select text:-N does not display the contents of the default buffer,-P forces the contents of the buffer to appear sed-n ' 1,3p ' students.txt #只显示1 the line
  • Replacement text: [ADDRESS1[,ADDRESS2]] s/pattern/replacemen/[flag] sed ' 1,3 s/e/e/g ' students.txt #替换1 all lowercase e in the line is capital letter E
  • Delete text: [address1[,address2]] d sed ' 1,4 d ' students.txt #删除1到4行 sed '/^$/d ' students.txt #删除空行
  • Insert text: [Address1] I string sed ' 2 i 200200109 Tom ' Students.txt #在第二行插入200200109 Tom Records.

Common shell commands

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: 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.