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/
REFERENCED:
►
WANT TO SUPPORT THE CHANNEL?
💰 Patreon:
💳 Paypal:
🛍️ Amazon:
👕 Teespring:
SOCIAL PLATFORMS:
🗨️ Mastodon:
💬 IRC: irc://freenode #distrotube
👫 Reddit:
📽️ LBRY:
DT ON THE WEB:
🕸️ Website:
🐿️ Gopherhole: gopher://distro.tube
📁 GitLab:
FREE AND OPEN SOURCE SOFTWARE THAT I USE:
🌐 Brave Browser –
📽️ Open Broadcaster Software:
🎬 Kdenlive:
🎨 GIMP:
🔊 Audacity:
💻 VirtualBox:
Your support is very much appreciated. Thanks, guys!
Nguồn: https://ftlinuxcourse.com
Xem thêm bài viết khác: https://ftlinuxcourse.com/lap-trinh-linux
Xem thêm Bài Viết:
- Trải nghiệm mới hay ho với hướng dẫn cài Mac Os trên vmware
- Bật mí cách cài đặt ssl miễn phí lên Let’s Encrypt
- Tuyệt chiêu tạo usb boot kali linux đơn giản dành cho bạn
- Hướng dẫn chi tiết từ A – Z các bước cài đặt Python trên Windows 10
- Bật mí quy trình cài đặt Kali Linux trên Vmware đúng chuẩn và chi tiết
@DistroTube!!
You got any link for a good video about just RegExp?
I read alot even seen some vids and still got real problems handling this.
You should mention the "echo test?.txt" trick to check what the pattern matches. Also backslash as a escape and single quotes to turn globing off
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.
thank you for the detailed video about file globing, I got a question, it might seem for you or for many easy stuff, but for me I feel confused, what is the difference between forking and subshell?
I mean they seem very similar both copy the shell as the "Linux Command Line and Shell Scripting Bible" said, the book didn't say that literally but they have the picture for forking and subshelling, however, I research that and it made it worst 😥
Any chance you can do a video on how you colorize your shell output? I have a theme in my terminal but I don't have different colors for certain columns. What about manpage coloring? Can you throw it in as well? Cheers!
Is that a Hugo project folder? Saw the config.toml file
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.
The 'g' in "RegEx" is pronounced the same as the 'g' in "Regular"
Hey man, thanks for all the awesome videos. I'm learning Linux again!
Starting at 6:36 "There is no …." Oops …………………. Of course it is possible to use the square bracket wildcard in SQL:
https://www.techonthenet.com/sql_server/like.php
https://www.tutorialgateway.org/sql-like/
https://www.educba.com/wildcards-in-mysql/
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 ~/.[!.]*
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.
Back in the days when people still used MS-DOS every somewhat experienced PC-user knew about this. DT, you shouldn't have cut out the for-loop (I assume that you created those files with a for-loop and touch) in my opinion.
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
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.
What's the command for restoring the deleted .txt test files?
I'm a glob denier, flat erf rulez 😏
1:55
touch file{1..10}.txt
you can iterate to 10 and make bash do the work for you! typing that long touch command is a chore.
Asterix symbol? What about the Obelix symbol?
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 !
Great video.
Very useful info.
Thank you, Derek. Good stuff.
Fun fact: GNU grep can be used to express regular languages, but not all grep regexes express regular languages.
Something to throw in my Hat about Linux.
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.
touch file{1..10}.txt 🙂