Command Line Basics#
Hello Terminal!#
Print your name to the terminal.
Clear your terminal after completing #1.
Solution to
echo Gökçe
clear
Creation and Inspection#
Create a new directory called
workbench
in your home directory.Without changing directories create a file called
readme.txt
inside ofworkbench
.Append the numbers 1, 2, and 3 to
readme.txt
so that each number appears on it’s own line.Print
readme.txt
to the command line.Use output redirection to create a new file in the
workbench
directory calledlist.txt
which lists the files and folders in your home directory.Find out how many characters are in
list.txt
without opening the file or printing it to the command line.
Solution to
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.txt
in your home directory and move it into another directory.Copy the
message.txt
you just moved into your home directory.Delete both copies of
message.txt
. Try to do this without usingrm
.
Solution to
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