The first glob we'll learn is *
.
When it encounters a *
character in any argument, the shell will treat it as "wildcard" and try to replace that argument with any files that match the pattern.
It's easier to show you than explain:
hacker@dojo:~$ touch file_a
hacker@dojo:~$ touch file_b
hacker@dojo:~$ touch file_c
hacker@dojo:~$ ls
file_a file_b file_c
hacker@dojo:~$ echo Look: file_*
Look: file_a file_b file_c
Of course, though in this case, the glob resulted in multiple arguments, it can just as simply match only one.
For example:
hacker@dojo:~$ touch file_a
hacker@dojo:~$ ls
file_a
hacker@dojo:~$ echo Look: file_*
Look: file_a
When zero files are matched, by default, the shell leaves the glob unchanged:
hacker@dojo:~$ touch file_a
hacker@dojo:~$ ls
file_a
hacker@dojo:~$ echo Look: nope_*
Look: nope_*
The *
matches any part of the filename except for /
or a leading .
character.
For example:
hacker@dojo:~$ echo ONE: /ho*/*ck*
ONE: /home/hacker
hacker@dojo:~$ echo TWO: /*/hacker
TWO: /home/hacker
hacker@dojo:~$ echo THREE: ../*
THREE: ../hacker
Now, practice this yourself!
Starting from your home directory, change your directory to /challenge
, but use globbing to keep the argument you pass to cd
to at most four characters!
Once you're there, run /challenge/run
for the flag!