Home > OS >  Consult everybody, grep how regular expressions work
Consult everybody, grep how regular expressions work

Time:11-13

Ask a question
Ls | grep [^ \]
I expect the result is file name does not contain. File, seems to be to find the file content can actually come out of,

CodePudding user response:

Grep -r "name". Add/r recursive search under the current directory

CodePudding user response:

Regular used to match a string, if want to pick up the words you can use the parameters of the grep -v

Do not include the files can be used. The following two kinds, you try

Ls -a | grep -v "\."
This is regardless of whether the opening

Ls -a | grep -v - E "^ \."
Filter only, at the beginning of

CodePudding user response:

reference 1st floor W_s_j response:
grep -r "name". Add/r in the current directory recursively find

I'm not a recursive

CodePudding user response:

refer to the second floor mountain pepper PI response:
regular used to match a string, if want to pick up the can use the parameters of the grep -v

Do not include the files can be used. The following two kinds, you try

Ls -a | grep -v "\."
This is regardless of whether the opening

Ls -a | grep -v - E "^ \."
Filtering, only at the beginning of

Tried, I can't

CodePudding user response:

reference 4 floor weixin_45621200 response:
Quote: refer to the second floor mountain pepper PI response:
regular used to match a string, if want to pick up the can use the parameters of the grep -v

Do not include the files can be used. The following two kinds, you try

Ls -a | grep -v "\."
This is regardless of whether the opening

Ls -a | grep -v - E "^ \."
Filtering, only at the beginning of

Tried, no


Why not? Does not comply with the conditions under the file name is listed? The filter for beginning. Filtering is... There are hidden files, these can show?

CodePudding user response:

mountain pepper PI reference 5 floor response:
Quote: refer to 4th floor weixin_45621200 response:
Quote: refer to the second floor mountain pepper PI response:
regular used to match a string, if want to pick up the can use the parameters of the grep -v

Do not include the files can be used. The following two kinds, you try

Ls -a | grep -v "\."
This is regardless of whether the opening

Ls -a | grep -v - E "^ \."
Filtering, only at the beginning of

Tried, no


Why not? Does not comply with the conditions under the file name is listed? The filter for beginning. Filtering is... There are hidden files, these can show?

I do not see out, but does not contain many names. All out, ls | grep -v \.

CodePudding user response:

mountain pepper PI reference 5 floor response:
Quote: refer to 4th floor weixin_45621200 response:
Quote: refer to the second floor mountain pepper PI response:
regular used to match a string, if want to pick up the can use the parameters of the grep -v

Do not include the files can be used. The following two kinds, you try

Ls -a | grep -v "\."
This is regardless of whether the opening

Ls -a | grep -v - E "^ \."
Filtering, only at the beginning of

Tried, no


Why not? Does not comply with the conditions under the file name is listed? The filter for beginning. Filtering is... There are hidden files, these can show?

I do not see out, but does not contain many names. All out, ls | grep -v \.

CodePudding user response:

mountain pepper PI reference 5 floor response:
Quote: refer to 4th floor weixin_45621200 response:
Quote: refer to the second floor mountain pepper PI response:
regular used to match a string, if want to pick up the can use the parameters of the grep -v

Do not include the files can be used. The following two kinds, you try

Ls -a | grep -v "\."
This is regardless of whether the opening

Ls -a | grep -v - E "^ \."
Filtering, only at the beginning of

Tried, no


Why not? Does not comply with the conditions under the file name is listed? The filter for beginning. Filtering is... There are hidden files, these can show?

I do not see out, but does not contain many names. All out, ls | grep -v \.

CodePudding user response:

refer to the eighth floor weixin_45621200 response:
Quote: refer to fifth floor mountain pepper PI response:
Quote: refer to 4th floor weixin_45621200 response:
Quote: refer to the second floor mountain pepper PI response:
regular used to match a string, if want to invert the parameters of can use grep -v

Do not include the files can be used. The following two kinds, you try

Ls -a | grep -v "\."
This is regardless of whether the opening

Ls -a | grep -v - E "^ \."
Filtering, only at the beginning of

Tried, no




Why not? Does not comply with the conditions under the file name is listed? The filter for beginning. Filtering is... There are hidden files, these can show?

I do not see out, but does not contain many names. All came out, the ls | grep -v \.




Does not contain many names. All out, that is not right? Is not does not contain. Do you want? If you want to contain. Then remove the -v
In addition, if you don't want to match. At the beginning, there would be no need to use regular expressions
  • Related