Linux wildcard characters

Source: Internet
Author: User

Linuxwildcard characters1.1 * all wildcard symbols ----Find a file 1.1.1 Creating an environment

mkdir/oldboy/20170118

cd/oldboy/20170118

Touchstu{00..10}.txt Oldboy{00..10}.log

Toucholdboy.txt Stu.txt

1.1.2 Find out the beginning of Stu

find/oldboy/20170118/-type f-name "stu*"

1.1.3 ###### The file that starts with Stu and ends in. txt in the current directory

method One: ls stu*.txt

Method Two: find-type f-name "*.txt" |ls stu*

Method Three: find-type f-name "Stu*.txt"

method Four: find-type f-name "stu*"-name "*.txt "

1.1.4 # # # # # # # # # Find the file in the current directory that contains (as long as there is a line)Oldboy

method One: find-type f-name "oldboy*"

Method Two: ls *oldboy*

Method Three: sed-n "/*oldboy*/p"

1.1.5 {} curly braces generate sequence

echo {1..9} display 1-9

Echo stu{1..10} display STU1-STU10

echo stu{1..10}|xargs-n1 displays stu1-stu9, and is displayed as vertical lines

echo {1,2,10} display 1,2,10

Echo A{b,c} show AB AC

Echo A{,c} display A AC

Echo Oldboy.txt{,.bak} shows oldboy.txt Oldboy.txt.bak

Cp/oldboy/20170118/oldboy.txt{,.bak} Backup Oldboy.txt.bak

Ls-l oldboy.txt*

-rw-r--r--1 root root 0 may 18:43 Oldboy.txt

-rw-r--r--1 root root 0 may 19:27 Oldboy.txt.bak

1.1.5.1 Example:

[[Email protected]]# echo {1..10}

12 3 4 5 6 7 8 9 10

[[Email protected]]# echo {1..10..2}

13 5 7 9

[Email protected]]# echo {a]. Z.. 2}

AC e g i k m o q s u w y

1.2 command Prompt for ordinary users

>> [ standard output ] add content to the last line of the file

> Output redirect danger Empty the contents of the file before appending the contents to the last line of the file

/ root /etc/hosts path split symbol

$ $LANG Take out the contents of the variable

awk shows a column

< input redirection

<< Append input redirection

&& When a command executes successfully, the following command is executed

|| When an instruction execution fails, the following command is executed

1.3 Root User's command prompt

. current directory

. bashrc. Bash_profile hidden files or directories ls-a

.. Top level directory of current directory

~ Current user's home directory

| Piping

or (Regular expression egrep)

# Explanatory notes

1.4 single quotes, double quotes, unquoted differences:

1.4.1 single quotation mark

What you see is what you get, what you eat and vomit.

1.4.2 Double quotes

Will parse the special symbol

1.4.3 without quotation marks

Similar to double quotes, but wildcard characters are supported

[Email protected] ~]# #1. single quotation marks

[[email protected] ~]# echo ' $LANG $ (which mkdir) {a]. Z} '

$LANG $ (which mkdir) {a}. Z

[Email protected] ~]# #2. Double quotes

[[email protected] ~]# echo "$LANG $ (which mkdir) {a]. Z} "

en_US. UTF-8/bin/mkdir {A.. Z

[Email protected] ~]#

[Email protected] ~]# #3. No quotes

[[email protected] ~]# Echo$lang $ (which mkdir) {a]. Z

en_US. UTF-8/bin/mkdir a b c D ef g h i j k l m n o p q R S t u v w x y Z


This article is from the "Heyong" blog, make sure to keep this source http://heyong.blog.51cto.com/13121269/1954024

Linux wildcard characters

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.