• Vehicles • Fashion • Recipes • Blogs • Hunt • Travels • Sport • Fun • Handmade • IT • Education
Mini-Games
x

x
zakruti.com » IT - Software » IT, programs, coding
File Globbing In Linux DistroTube

File Globbing In Linux DistroTube

FBTwitterReddit

video description

Rating: 4.0; Vote: 1
File Globbing In Linux DistroTube File globbing refers to -global- patterns that specify sets of filenames with wildcard characters. Globbing is the - and ? and some other pattern matchers you may be familiar with. An example would be doing something like the following in the Bash shell: cp -.txt /Documents/text/ - https://www.distrotube.com/blog/file-globbing-in-linux/
Date: 2022-03-30

Comments and reviews: 10


I didn't know that you can use ! instead of -.
- still seems preferable to me because it's exactly the same syntax that will be needed when later learning regexps.
I understand why you might avoid getting into the translation between globbing/shell patterns, but I think the basic rules can be summarized pretty succinctly:
'-' in glob translates to '.-' ('any character' + '0 or more of') in regexp
'?' in glob translates to '.' ('any character'; without the '0 or more of' modifier, this matches exactly 1 character)
'[...]' in glob translates to .. exactly the same in regexp (with some exceptions relating mainly to the use of backslashes)
'[!...]' or '[-...]' in glob is as stated above, '[-...]' in regexp
. , (, ), $, - in glob (outside of a character class) should be prefixed with a backslash for regexp
One other thing I think maybe should be mentioned is that the subject you actually covered was _POSIX_ file globbing ('sh' / 'bash' without the 'extglob' option set), and other shells may have more (zsh, bash _with_ the extglob option set) or less (fish) sophisticated globbing available.

reply

As an exercise, how would you write a wildcard to match dotfiles in your home directory? These are the various files/directories containing user preferences for apps that you run. Their names begin with a dot, so they are normally excluded from directory listings. However, if you type something like -ls -ld -/.--, it will also show the useless -.- and -..- entries that clutter every Unix/Linux directory. How do you exclude these?
The answer is:
ls -ld -/.[!.]-

reply

Back in the good old days, my parents got a computer. I think it was their first personal computer. my mom accidentally copied a chess game over a DOS install so whenever the pc booted it would run the chess game. She did some -copy -.-- command. It prompted my dad to become somewhat of a DOS guru so he could fix it. So because of this, I've known about wildcards and the dangers of haphazard commands since I can remember xD
reply

There's not just file globbing either, there's the standard globbing (can't remember it's name) you use, for example, in case statements.
Would be interesting to see you make a REGEX video, too. By the way, it's hard G, because re[g]ular expressions.

reply

Always test you command with ls or select in SQL before you use wildcard so you sure it does what you want ! But it's a good reminder of the basic command. As always, Great Job, Derek !
reply

Hey #distrotube would you please take a look on Extern Os( i just found that based on ubuntu but they haven't mention on any where on there page.) quite confusing Os(at least i think)
reply

Nothing like Globbing to get some work done.. It is strange the names that Linux folks come up with... I just go with it as it is really neat! Thanks DT for the video!
LLAP

reply

7:10 If you want to use regexes to match file names, you can do so with the -find- command. That-s a very useful command, by the way; worth doing an episode on, I think.
reply

I love the Matrix screensaver but stopped using them when I caught a trojan in one; know where I can get one that is clean? Thanks for the refresh on globs.
reply

I mean why not just use commands like
>ls file[0-9].txt
it would show what's being filtered without you needing to remove files and retouch them.

reply
Add a review, comment






Other channel videos