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
@Phydoux21124 жыл бұрын
My first introduction to the * was with the Commodore 64. LOAD"*",8,1 which loaded the first file on the disk. Oh, how far I've come from the Commodore 64 to installing a hard drive on a Commodore 64, to DOS, to Windows, and finally to Arch Linux. It's been a bumpy ride these last 40 or so years. But it's been a lot of fun. I've enjoyed the evolution of computers on my end.
@jaiden914 жыл бұрын
touch file{1..10}.txt :)
@DistroTube4 жыл бұрын
Was waiting for someone to mention this. Surprised it took so long. ;)
@Khyree_Holmes4 жыл бұрын
hey! I tried to do that, brain fart.... got it now.
@lawrencedoliveiro91044 жыл бұрын
Sometimes you need to feed the files to a command one at a time. This works with bash: for i in {1..10}; do echo file${i}.txt; done Sometimes you need leading zeroes on the numbers. This also works with bash: for i in {01..10}; do echo file${i}.txt; done If you are using a more minimal shell (e.g. dash) that doesn’t do “{..}” pattern expansion, there is always the “seq” command: for i in $(seq 1 10); do echo file${i}.txt ; done If you want the leading zeroes, seq won’t do them, so try the “printf” command: for i in $(seq 1 10); do echo file$(printf %02d ${i}).txt ; done
@dkosmari4 жыл бұрын
Maybe for next video, bash variable evaluation witchcraft.
@dingokidneys4 жыл бұрын
@@kirschkern8260 This is not actually copy/paste. Many terminals though (not shells) do have a copy/paste function . E.g. Terminator (and some others) use Ctrl+Shift+c and Ctrl+Shift+v to copy and paste. Just highlight with the mouse cursor and off you go. Sometimes you can just highlight text in the terminal then right click and it will be pasted onto the command line. Useful.
@BrucesWorldofStuff4 жыл бұрын
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
@lawrencedoliveiro91044 жыл бұрын
The name dates from UNIX. Linux inherited a lot of old UNIX culture.
@fredhair4 жыл бұрын
Asterix symbol? What about the Obelix symbol?
@fredhair4 жыл бұрын
@@peterjansen4826 Me too, I know the books are available over there but not sure if they're popular. I'm in the UK and love them :)
@The_Penguin_City2 жыл бұрын
Caius Trolebus symbol too.
@berndeckenfels4 жыл бұрын
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
@d_rooster4 жыл бұрын
Hey man, thanks for all the awesome videos. I'm learning Linux again!
@AnzanHoshinRoshi4 жыл бұрын
Thank you, Derek. Good stuff.
@surferbum6184 жыл бұрын
Thanks for all you do DT
@shady4tv4 жыл бұрын
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.
@TrouvatkiDePercusion4 жыл бұрын
I was wondering why he would do it the long way.
@___91364 жыл бұрын
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.
@lawrencedoliveiro91044 жыл бұрын
“!” being POSIX is more likely to be supported by other shells besides Bash.
@___91364 жыл бұрын
@@lawrencedoliveiro9104 I didn't know that. Testing a little, I can see that 'dash' supports only !. bash supports ^ and ! in both its normal and 'pretending to be sh' instances. 'ksh' supports ! and ^. tcsh supports only ^, not ! (! produces an 'event not found' error)
@lawrencedoliveiro91044 жыл бұрын
@@___9136 dash seems to be a good, minimal, POSIX-compliant shell. Nobody should be using tcsh or csh-derivative shells any more.
@___91364 жыл бұрын
@@lawrencedoliveiro9104 I don't disagree (most of these I installed only for testing), but I do feel obligated to point out that the fact that tcsh was in Arch's community repo indicates that a minimum of 1000 people are in fact using it.
@mohammedhattab45942 жыл бұрын
Great quality content!!
@brianstrong88414 жыл бұрын
that was great
@lawrencedoliveiro91044 жыл бұрын
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.
@___91364 жыл бұрын
It's a very indepth command. The simplified finder `fd` has mostly replaced find, for me. Much easier to, for example, get files with one of several acceptable extensions (eg. png,jpg,gif)
@lawrencedoliveiro91044 жыл бұрын
I use “find -exec” all the time.
@___91364 жыл бұрын
@@lawrencedoliveiro9104 Fair enough. I usually pipe to xargs unless I really need something sophisticated.
@lawrencedoliveiro91044 жыл бұрын
@@___9136 That’s for acting on the results of the find. -exec is useful for applying a custom filter.
@ovieoyegwa61534 жыл бұрын
i followed through. thanks
@DJ_Cthulhu4 жыл бұрын
I'm a glob denier, flat erf rulez 😏
@primokorn1 Жыл бұрын
Great video. So file globbing is the same as regular expressions. It would be appreciated to have the shell in full screen 👍 not very easy to follow on my phone. Thank you.
@1yaz4 жыл бұрын
Fun fact: GNU grep can be used to express regular languages, but not all grep regexes express regular languages.
@lawrencedoliveiro91044 жыл бұрын
Hint: the “reg” in “regex” is short for for “regular”.
@Arkayaplays4 жыл бұрын
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)
@a13xhackintosh3 жыл бұрын
This is a topic I failed in interview lol 😂😆😂😆😂
@Khyree_Holmes4 жыл бұрын
Something to throw in my Hat about Linux.
@sumanthcheedepudi87513 жыл бұрын
how to use globbing to list all the folders whose name doesn't contain a specific character. I tried this: LS *[!a]* ,which is not working.
@The_Penguin_City2 жыл бұрын
Shopt -s extglob and exdot make you able to use glob characters if you can't.
@AliensInc.4 жыл бұрын
@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.
@lilxghostt3 жыл бұрын
I wish you where my Linux teacher
@michalroesler2 жыл бұрын
I wanna learn this new skill.
@lerrz89694 жыл бұрын
how bout display all files in the current directory that begins with test, only has 5 characters and does not have a 1,5,7 as the last character
@lawrencedoliveiro91044 жыл бұрын
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 ~/.[!.]*
@serge50464 жыл бұрын
There is even a simpler solution for it: just use the -A option of ls
@lawrencedoliveiro91044 жыл бұрын
@@serge5046 That won’t work if you just want directories, though: du -ks ~/.[!.]*/
@The_Penguin_City2 жыл бұрын
Shopt -s dotglob
@robertcatesby48004 жыл бұрын
What's the command for restoring the deleted .txt test files?
@DistroTube4 жыл бұрын
There isn't an undo command. You simply create them again. I just created a bunch of empty files with touch: touch file1.txt file2.txt etc etc ... Because the names are so similar, something like the following works: touch file{1..10}.txt
@robertcatesby48004 жыл бұрын
Thanks. That's a cool one for the toolbox.
@TimothyEdgin4 жыл бұрын
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.
@lawrencedoliveiro91044 жыл бұрын
I like to use the xscreensaver package: packages.debian.org/buster/xscreensaver
@Tout-Le-Monde024 жыл бұрын
Is that a Hugo project folder? Saw the config.toml file
@DistroTube4 жыл бұрын
Yea, just copied my hugo directory into that test directory.
@SuperWolfkin4 жыл бұрын
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.
@subbus-g3 жыл бұрын
yeah, that's great. Also by using ls some_pattern before rm some_pattern we can ensure by seeing what files we are going to delete
@optimalcomrad4 жыл бұрын
First
@DistroTube4 жыл бұрын
It's official.
@lescitrons4 жыл бұрын
e
@nerrufam71054 жыл бұрын
The 'g' in "RegEx" is pronounced the same as the 'g' in "Regular"