Can you provide more examples?

QuestionsQuestions4 SkillsProBasic Files OperationsSep, 13 2025
0164

Sure! Here are more examples of useful Bash shortcuts and commands:

  1. ~ (Home Directory):

    cd ~/Documents
    

    Navigates to the Documents folder in your home directory.

  2. . (Current Directory):

    cp file.txt ./backup/
    

    Copies file.txt to the backup directory within the current directory.

  3. .. (Parent Directory):

    cd ../..
    

    Moves up two directory levels.

  4. - (Previous Directory):

    cd -
    

    Switches back to the last directory you were in.

  5. $PATH (Executable Path):

    export PATH=$PATH:/new/directory
    

    Adds a new directory to your executable path.

  6. * (Wildcard):

    rm *.log
    

    Deletes all files with a .log extension in the current directory.

  7. ? (Single Character Wildcard):

    ls file?.txt
    

    Lists files like file1.txt, file2.txt, etc.

  8. & (Background Process):

    python script.py &
    

    Runs script.py in the background.

  9. Ctrl + C (Cancel Command):

    • Use this to stop a running command, like a long-running script.
  10. Ctrl + Z (Suspend Command):

    • Suspends a running command, which you can resume with fg (foreground) or bg (background).
  11. history:

    history
    

    Displays a list of previously executed commands.

  12. !! (Repeat Last Command):

    !!
    

    Repeats the last command you executed.

  13. !n (Repeat Command by Number):

    !100
    

    Executes the command listed as number 100 in your history.

These examples illustrate how you can use shortcuts and commands to navigate and manage files efficiently in the Bash shell. If you need more specific examples or have a particular use case in mind, let me know!

0 Comments

no data
Be the first to share your comment!