Command Line Basics
Command Line Basics#
Print your name to the terminal.
Clear your terminal after completing #1.
Solution to Exercise 1
echo Gökçe clear
Creation and Inspection#
Create a new directory called
workbenchin your home directory.
Without changing directories create a file called
Append the numbers 1, 2, and 3 to
readme.txtso that each number appears on it’s own line.
readme.txtto the command line.
Use output redirection to create a new file in the
list.txtwhich lists the files and folders in your home directory.
Find out how many characters are in
list.txtwithout opening the file or printing it to the command line.
Solution to Exercise 3
cd mkdir workbench touch workbench/readme.txt echo -e '1\n2\n3' >> workbench/readme.txt # in bash, echo needs -n to account for backslash escapes cat workbench/readme.txt ls > workbench/list.txt wc --chars workbench/list.txt
Migration and Destruction#
Create a file called
message.txtin your home directory and move it into another directory.
message.txtyou just moved into your home directory.
Delete both copies of
message.txt. Try to do this without using
Solution to Exercise 4
cd # change directory again, the directory is not preserved between %%sh cells # compared to the bash-kernel echo secret > message.txt mv message.txt workbench cp workbench/message.txt ~ mkdir trash mv message.txt workbench/message.txt trash # or a trash dir may already be available # mv message.txt .local/share/Trash # or if `trash-cli` is installed # trash message.txt rm -r trash workbench
For further solutions to 3 see this posting at Stack Exchange