Linux Wildcard Character

LinuxLinuxBeginner
Practice Now

Introduction

Welcome to the futuristic underwater city of Atlantis! As a deep-sea explorer, you have been tasked with navigating the intricate network of undersea tunnels to collect valuable data and samples. Your mission is to utilize the wildcard feature of Linux to efficiently locate and manipulate files within the complex structure of the underwater city.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/FileandDirectoryManagementGroup(["`File and Directory Management`"]) linux/FileandDirectoryManagementGroup -.-> linux/wildcard("`Wildcard Character`") subgraph Lab Skills linux/wildcard -.-> lab-271447{{"`Linux Wildcard Character`"}} end

Introduction to Wildcards

In this step, you will learn the basics of using wildcards to perform file operations in the Linux environment.

  1. Open your zsh terminal and navigate to the directory ~/project.

    cd ~/project
  2. Create three text files with names file1.txt, file2.txt, and file3.txt.

    for i in {1,2,3}; do touch file$i.txt; done
  3. Use the ls command with wildcards to list all the text files in the directory.

    ls file*.txt

    This command should display the names of all three text files.

    file1.txt  file2.txt  file3.txt

Using Wildcards for File Removal

In this step, you will explore how wildcards can be used to remove multiple files simultaneously.

  1. Using the rm command with wildcards, delete all the text files in the directory.
    rm file*.txt

Wildcards with File Manipulation

For the final step, you will use wildcards to rename and copy files with specific patterns.

  1. Create a new directory named backup within the ~/project directory.
    mkdir ~/project/backup
  2. Use wildcards to copy all the text files created in the step1 with names starting with "file" into the backup directory.
    cp file*.txt ~/project/backup/

Summary

In this lab, you have been immersed in the fascinating world of Linux wildcards. By mastering the use of wildcards, you have learned how to efficiently manipulate files based on patterns, simplifying complex file operations. This critical skill will undoubtedly enhance your ability to navigate and manage files within the challenging environment of the underwater city.

Other Linux Tutorials you may like