Use command-line tools to find and manipulate files that comply with specific criteria.
Outcomes
Use globbing to process several files with a single command line.
Use an escape character to prevent globbing.
As the student user on the workstation machine, use the lab command to prepare your environment for this exercise, and to ensure that all required resources are available.
[student@workstation ~]$ lab start filesystem-batch
Instructions
Review the contents of the student user home directory.
[student@workstation ~]$ tree
...output omitted...
├── Downloads
│ ├── fedora.md
│ ├── files.txt
│ ├── help.md
│ ├── meeting.txt
│ └── notes.txt
├── Music
...output omitted...
8 directories, 5 filesCopy all the files in the Downloads directory that end in the letter d to the Documents directory.
[student@workstation ~]$ cp D*ds/*d DocumentsConfirm that the fedora.md and help.md files have been copied.
[student@workstation ~]$ ls Documents
fedora.md help.mdCopy all the files in the Downloads directory that start with f and end in txt to the Documents directory.
[student@workstation ~]$ cp D*ds/f*t DocumentsConfirm that the file.txt and files.txt files have been copied.
[student@workstation ~]$ ls Documents
fedora.md files.txt help.mdUse globbing to move only the files.txt and notes.txt files to the Desktop directory.
[student@workstation ~]$ mv D*ds/?????.* ~/DesktopSearch the Desktop directory and use globbing to confirm that the files.txt and notes.txt files have been moved.
[student@workstation ~]$ find ~/Desktop -iname ?????.*
/home/student/Desktop/files.txt
/home/student/Desktop/notes.txtUse an escape character to create the ex*mple.txt file that contains the string Hello World!.
[student@workstation ~]$ echo "Hello World!" > Documents/ex\*mple.txtConfirm the file's name and contents by using a backslash to escape the file name.
[student@workstation ~]$ cat Documents/ex\*mple.txt
Hello World!Find all files in the home directory that contain an asterisk (*) character in its name.
Use redirection to save the results in the ~/wildcard.txt file.
Because the home directory is your current directory, you can use a period (.) to refer to the home directory.
[student@workstation ~]$ find . -iname "*\**" > wildcard.txtReview the wildcard.txt file contents.
[student@workstation ~]$ cat wildcard.txt
./Documents/ex*mple.txt