Topic 2: In-Class Activity - Exploring the Command Line
In-Class Activity: Exploring the Command Line
Objective: The goal of this activity is to put into practice the shell commands learned in class, including file navigation, file manipulation, and simple scripting.
Instructions:
- Shell Basics:
- Open your terminal or command line interface.
- Identify which shell you are using with the command
echo $SHELL. - Use
manor--helpto look up the manual for thelscommand.
- Help!:
- For each of the following commands, use
--helpormanto find out what they do:cd,mkdir,rm.
- For each of the following commands, use
- Navigating Your System:
- Navigate to your home directory using
cd. - List all the files and directories in your home directory with a detailed view using
ls -l. - Create a new directory called
ds_activities.
- Navigate to your home directory using
- Managing Your Files:
- Inside
ds_activities, create a new file calledmy_script.sh. - Copy any text file from your system into this directory and rename it to
sample.txt.
- Inside
- Working with Text Files:
- Use
catto display the contents ofsample.txt. - Use
headandtailto display the first and last 10 lines ofsample.txt.
- Use
- Redirects, Pipes, and Loops:
- Redirect the output of
ls -lto a file nameddirectory_list.txt. - Use a pipe to sort
directory_list.txtalphabetically and display the results withless.
- Redirect the output of
- Scripting:
- Edit
my_script.shto include abashscript that prints “Hello, Data Science!” to the terminal. - Make
my_script.shexecutable withchmodand run it.
- Edit
Submission: - Compress the ds_activities directory with all created files into a .zip file and submit it through Gradescope in the Lecture Quiz 06. - Name the zip file FirstName_LastName_ds_activities.zip.
Note: Remember to replace FirstName and LastName with your actual last and first names.