shell - Expansion in Linux -


I was reading the tutorial below

This is about double quotes In: / P>

double quote

We will see double quotes of the kind of quote we have. If you place the text in double quotation marks, then all special characters used by the shell lose their particular meaning and are considered as normal characters. Exceptions are "$", "\" (backslash), and "` "(back-coat). This means that word-split, pathname extension, tilde extension, and brace detail are suppressed, but parameter extension, arithmetic expansion, and command replacement are still done.

And about single quotes:

Single quotes

If you need to suppress all the extensions, You can use quotes.

Why this LS why only *. Txt does not work "* .txt" or '*. Txt '

  $ ls -l * .txt -rw-r - r-- 1 Noble No 8893 Apr 17 06:25 BigText.txt -rwxr-xr-x 1 Pride None 54376 Apr 18 12:32 File .txt -rw-r - r-- 1 Noble No 371 Apr 23 21:04 Filelists. TT-RWXR-XR-X1 Pride None 54386 April 18 12:28 File Old. Txt -R-R-R-R-1 Pride 1963 April 17 06:19 Readet Text- rw-r - r-- 1 Noble No 651 April 24 06:28 $ temp.txt $ ls -l "* .txt" can not access ls: * .txt: Any such file or directory $ ls -l '* .txt' ls: * Can not access .txt: Not a file or directory  

My question is, why, with find or grep why "* .txt ", '* .txt' provide both extensions:

For example

 

> Find $ -Name * .txt Search: Path must be before expression: File.txt Usage: Search [-H] [-L] [-P] [-Oolaval] [-D Help | Tree | Search | State | Rate | Opt. Exec] [path ...] [expression] $ find-name "* .txt" ./bigText.txt ./file.txt ./Filelist.txt ./FileOld.txt ./Read.txt ./sample/BigText .txt ./sample/File.txt ./sample/ FileOld.txt ./sample/Read.txt ./sample/temp.txt ./temp.txt $ find -name '* .txt' ./BigText.txt. /File.txt ./Filelist.txt ./FileOld.txt ./Read.txt ./sample/BigText.txt ./sample/File.txt ./sample/ FileOld.txt ./sample/Read.txt ./sample /temp.txt ./temp.txt

find Enter your * and ndash; There is no need for a shell to do this.

If you write commands in the shell (or when shell executes a command from a script), then it should be aware of what happens to you:

First of all, all the extensions Variable detail (like $ foo is changed to the value of foo ), like the extension of the tilde ( ~ < / Code> changes to the home directory path) and globing (turns * in all the codes).

Then, after that extension

when you call search , you do not actually open do not want to expand, * which you pass as find as part of a pattern, because search command < Code> * and use it as a search pattern (like find

gt; -name '* .foo' ).


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -