Managing Files and Folders on PythonAnywhere with Bash Commands
Introduction
- The task of creating, managing and removing directories and files in Bash is essential to understand on how to make a front and backend programs.
Creating Directories
To create a directory in Bash use
mkdir foldername
command and to create multiple directories like 20 directories do:mkdir documents pictures downloads music videos projects notes backups reports logs_work templates drafts code images scripts tests archives configs keys resources
The purpose of this directories is to save any files you want example in documents folder we save 10 text files in that directory.
Adding Files
To add files inside a directory first you need to go to that directory to go to that directory use
cd foldername
command and usertouch filename
command to add files on that directory and to add multiple files like 10 files in that directory do:touch file1.txt file2.txt file3.txt file4.txt file5.txt file6.txt file7.txt file8.txt file9.txt file10.txt
To verify if the files is made use
ls
command this command will list all the files inside the directory.
Removing Files and Directories
To remove a file inside directory use the command
rm filename
and to remove files using this command do:rm file8.txt file9.txt file10.txt
To remove directory use the command
rm -r foldername
and to remove multiple directories do:rm -r backups configs downloads images logs_work notes projects resources templates videos
Conclusion
- We, Therefore conclude that this commands teach us on how to properly use the Bash to create directories and files and also how to remove it and then list all of this directories and files.
Code Snippets
Subscribe to my newsletter
Read articles from Cañete,Brandon L. directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by