In this lab, we are going to practice with bash
, a shell and command-line language!
-
Open a Terminal in your system:
- Linux/MacOS users: open a terminal in your system.
- Windows users: open GitBash in your system
-
Download and install the Sublime text editor for your OS here.
-
Open the Sublime text editor side by side with the Terminal.
-
Fork this repo in your git hub account and then clone it into the folder Week_1/Day_1/ of your machine. This will create a folder called "lab-bash" inside.
-
Use the terminal to navigate to the "lab-bash" folder.
-
Use the Sublime menu to open a new empty file in the "lab-bash" folder and name it "lab_solutions.txt".
-
Check the contents of the folder using the "ls" command in the Terminal.
ls
and 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.
-
To provide your solutions, test your solution in the terminal and once you figured out the solution to each exercise do the following:
- Copy the statement of each exercise on the "lab_solutions.txt" file opened in the Sublime text editor
- Add the Terminal command needed to solve each exercise on the "lab_solutions.txt" just below the exercise statement as shown below:
terminal_command # replace "terminal_command" with the command that you used in the terminal to solve the exercise
- Save the "lab_solutions.txt" file.
-
Once you finished all the exercises type the following in the Terminal:
- git status
- git add lab_solutions.txt
- git commit -m "Lab solutions"
- git push origin master
-
Copy the url of your forked GitHub repo on the student portal.
- Using the
echo
command print in console "Hello World". Here is some info about theecho
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.txt
from thelorem
folder and paste it to the folderlorem-copy
folder. - Copy the other two files from the
lorem folder
tolorem-copy
folder in just one line using the semicolon;
. - Show the
sed.txt
file content from thelorem
folder using the cat - Show the
at.txt
file andlorem.txt
file contents fromlorem
folder. - Print the first 3 rows in
sed.txt
file from lorem-copy folder using head - Print the last 3 rows in
sed.txt
file from lorem-copy folder using tail. - Add
Homo homini lupus.
at the end ofsed.txt
file in thelorem-copy
folder using >>. - Print the last 3 rows in
sed.txt
file fromlorem-copy
folder. You should seeHomo homini lupus.
. sed
command is used to replace the text in a file. Use thesed
command to replace all occurences ofet
withET
in the fileat.txt
file present in the folderlorem
. You can use the following link to refer tosed
commands [https://www.linode.com/docs/guides/manipulate-text-from-the-command-line-with-sed/] Check the contents of the sed.txt file usingcat
command.- Find who is the system user ( google is your friend ;) ).
- Find the current path of the directory you are in.
- List all files with the extension
.txt
in lorem folder. - Count the rows in
sed.txt
file from lorem folder. Look concatenatecat
andwc
with the pipe|
. - Count the files that start with
lorem
in all directories.