Recap - Selective Operations
Part of the Fundamentals section of Coddy's Terminal journey. Lesson 29 of 82.
Challenge
EasyPut all your wildcard skills together!
- Create a new directory called
archiveusingmkdir - Move only the single-digit
.jpgphoto files intoarchive/using the[0-9]bracket wildcard - Move all
report_?.txtfiles intoarchive/using the?wildcard - Delete all remaining
.pngfiles using the*wildcard - List the home directory with
lsto confirm what remains - List the archive folder with
ls archiveto confirm its contents
Note:
photo_10.jpgshould stay in the home directory. It has two digits so it won't be matched by[0-9]. Think carefully about which wildcard to use for each step!
The listing here sorts
photo_10.jpgbeforephoto_1.jpg:lsuses the sandbox locale, which ignores the underscore when comparing names. On your own machine the order may differ. Compare the set of files, not the order. The check looks at the final state of your files after all your commands, so it does not matter whether you list them in one command or two, or how many times you looked around on the way.
⚠ Clean up first: If you see unexpected directories (like
family,nature, ortravel) in your home directory, possibly left over from a previous lesson, remove them before running the steps above. Userm -rf <dirname>for each one (for example,rm -rf family). This ensures yourlsoutput matches the expected result.
Try it yourself
All lessons in Fundamentals
4Directories
Create A DirectoryCopy A DirectoryMove And Rename A DirectoryDelete A DirectoryRecap - Directory Operations7File Content
Head And TailWord CountSort CommandUnique CommandGrep BasicsGrep With FlagsRecap - Text Detective2Navigation
Print Working DirectoryList FilesChange DirectoryAbsolute vs Relative PathsHome And Root DirectoryRecap - Find Your Way8Redirection
Standard OutputOverwrite To A FileAppend To A FileStandard InputStandard ErrorRecap - Log Builder6Wildcards And Patterns
The Star WildcardThe Question Mark WildcardBracket WildcardsCombining WildcardsRecap - Selective Operations9Piping
What Is A PipeChaining Two CommandsChaining Multiple CommandsPipe With GrepRecap - Data PipelinePractice on your own: Terminal playground