Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
553 views
in Technique[技术] by (71.8m points)

linux - What is file globbing?

I was just wondering what is file globbing? I have never heard of it before and I couldn't find a definition when I tried looking for it online.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Globbing is the * and ? and some other pattern matchers you may be familiar with.

Globbing interprets the standard wild card characters * and ?, character lists in square brackets, and certain other special characters (such as ^ for negating the sense of a match).

When the shell sees a glob, it will perform pathname expansion and replace the glob with matching filenames when it invokes the program.

For an example of the * operator, say you want to copy all files with a .jpg extension in the current directory to somewhere else:

cp *.jpg /some/other/location

Here *.jpg is a glob pattern that matches all files ending in .jpg in the current directory. It's equivalent to (and much easier than) listing the current directory and typing in each file you want manually:

$ ls
cat.jpg dog.jpg drawing.png recipes.txt zebra.jpg

$ cp cat.jpg dog.jpg zebra.jpg /some/other/location

Note that it may look similar, but it is not the same as Regular Expressions.

You can find more detailed information here and here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...