Include filename expansion in `terminal_basics.txt`
Opened this issue · 1 comments
Shell Globbing
After the inclusion of tab completion in #30 the expansion of filenames by the shell using the asterisk *
wild card may additionally included.
The asterisk *
matches everything in the current directory (excluding ./
, ../
, and any filename starting with a period, e.g. .bashrc
) or the greatest possible match with the pattern given before or after it. This way, may similar files can be acted upon using only one command.
Example
Suppose there are several files in the current directory. Some are Python scripts ending in .py
, some are folders (indicated below with a trailing forward slash /
) starting with 001-
in their filename, and others match neither of these two requirements. A file listing may show:
001-1/ 001-4/ 001-7/ 001-do_not_delete.txt results/
001-2/ 001-5/ 001-8/ export-results.py run-calculations.py
001-3/ 001-6/ 001-9/ heisenberg.jpeg terminal_basics.txt
Suppose all folders starting with 001-
are to be deleted retainig the results
folder, all Python scripts copied one folder up, and all other files left untouched.
This can be acieved with two commands:
rm -r 001-*/
cp *.py ../
In the first line any file with a filename starting with 001-
and also ending with a /
(identifying it as directory) is deleted.
The second line matches any file with a filename ending in .py
.
The example listing after execution of the two commands is
001-do_not_delete.txt heisenberg.jpeg run-calculations.py
export-results.py results/ terminal_basics.txt
with only the undesired folders removed and the Python scripts also available in the folder above the current one.
This sounds like a good idea. Where would you put it?