In this lab, we are going to practice with bash, a shell and command-line language!
-
Fork the repo in your GitHub account, then clone the folder "lab-bash" to your machine and navigate to the folder.
-
Check the contents of the folder using the "ls" command.
$ lsand you should see the following:
exercises inputs lorem lorem-copy modules outputs README.md- Stay in the same directory/folder and complete the following exercises:
- Using the
echocommand to print "Hello World" in the console. Here is some info about echo command [https://discuss.codecademy.com/t/what-are-practical-uses-of-the-echo-command/394788] - Create a new directory called
new_dir. - Delete/Remove the directory
new_dir. - Copy the file
sed.txtfrom theloremfolder and paste it to the folderlorem-copy. - Copy the other two files from the
loremfolder to thelorem-copyfolder in just one line using semicolon;. - Show the content of the
sed.txtfile from theloremfolder. - Show the contents of the
at.txtfile and thelorem.txtfile from theloremfolder. - Print the first 3 rows in the
sed.txtfile from thelorem-copyfolder. - Print the last 3 rows in the
sed.txtfile from thelorem-copyfolder. - Add
Homo homini lupus.at the end of thesed.txtfile in thelorem-copyfolder. - Print the last 3 rows in
sed.txtfile fromlorem-copyfolder. You should seeHomo homini lupus.. sedcommand is used to replace the text in a file. Use thesedcommand to replace all occurances ofetwithET, in the fileat.txtfile present in the folderlorem. You can use the following link to refer tosedcommands [https://www.linode.com/docs/guides/manipulate-text-from-the-command-line-with-sed/] Check the contents of the sed.txt file using thecatcommand.- Find who is the system user.
- Find the current path of the directory you are in.
- List all files with the extension
.txtin the lorem folder. - Count the rows in the
sed.txtfile from lorem folder. Concatenatecatandwcwith the pipe|. - Count the files which start with
loremin all directories.
- Store your
namein a variable withreadcommand. - Print that variable.
- Create a new directory named with variable
name. - Remove that directory.
