Linux Learning Record-command substitution-wildcard-redirect-pipeline

Source: Internet
Author: User

Command substitution: $ (commands), ' command '

Touch./file-$ (date +%f-%h-%m_%s). txt


There are three types of quotes supported by bash:

": Command substitution

"": weak reference, can implement variable substitution

': Strong reference, do not complete variable substitution


File name wildcard globbing

* Any character of any length

? Arbitrary length single

[] matches any single character within the specified range

[^] outside of the matching range


> Coverage

>> Append Output

-C Disable Overwrite redirection for already existing files

Force overwrite output, use >|

+c turn off the above features


2> redirect Error output

2>> Append method

&> redirect error output or standard output to the same file


< input REDIRECT Cat </etc/fstab


Tr ' A-Z ' A-Z ' </etc/fstab

Cat/etc/fstab/etc/hosts

Cat << EOF Manual input content end with EOF

Cat >>/tmp/myfile.txt << EOF input part of the content is stored in myfile.txt


Pipeline

Take the output of one command as input to another command

echo "Hello, world." | Tr ' A-Z ' A-Z

Cut-d:-f1/etc/passwd | Sort | Tr ' A-Z ' A-Z

cat/etc/passwd | Wc-l number of statistics file lines

Tee output one copy, then save one copy

echo "Hello, world." | Tee/tmp/hello.out


Fetch the sixth line of the file

Head-6/etc/inittab | Tail-1

Take the Nineth line and show the username and shell

Tail-9/etc/passwd | head-1 | Cut-d:-f1,7 | Tee/tmp/users




















Linux Learning Record-command substitution-wildcard-redirect-pipeline

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.