In this lab session, you're supposed to learn the basics of bash and git.
Bash is the standard shell in many Linux distributions. Despite the ancient feeling, some tasks which are very tedious to do on a GUI can be solved pretty quickly on the command line. Especially if a task is very repetitive, there is a high chance that there exists a command line tool which can solve it faster.
Git is a version control system. Version control systems are primarily used in software development to keep track of all changes made by the software developers to any file within the software project. It keeps a version history and allows you to revert changes made to a file and to restore deleted files. Therefore, git is also useful if you work on a set of files on your own, but you want to keep track of every change you make and you want to be able to go back to a previous version if you make a mistake.
man(note the space), followed by the name of a command, to the command line.
In this exercise, you will use the most basic commands of git and bash. Make yourself familiar with these tools before we start with the more interesting part in Exercise 2.
ssh://email@example.com/opt/git/ti2fpinto a folder called
ti2fp. The username is
gitand the password is
ti2lab. (You will have to install git first.)
ti2fpfolder into this folder.
empty.txtin the text editor called
nano, add some text and save the file.
In this exercise, you will see some basic commands to read data from files. You can save the output of a program to a file by using redirects.
csv-filesfolder. There, you will find a number of
.csvfiles which contain stock prices of different stocks.
msft.csvon the terminal.
allTheData.csvthat contains every line from every
*.csvfile in the main folder.
.csvfiles and write them into the file
.csvfiles. Write the first 10 lines of every
.csvfile into the file
.csvfile into the file
In the previous exercise, all tasks could be solved with just one command by passing some parameters to this command. In this exercise, we will learn how to search for files by their name and their content. Moreover, you are supposed to use Pipes and (sometimes) the
xargs command to pass on the output of one command to another command.
Go to the
sourcecode folder. There, you will find hundreds of Java files in different subfolders. It would be tedious to open them all in a text editor if you were looking for something, wouldn't it?
.javafile (including the path to the files starting from the folder
sourcecode) into a file called
javain its filename. Write the output into the file
// Author: University of Zurich.
sourcecode/utils. Print every file in this folder that does not contain
DO NOT DELETE.
allSrc.txt(in the folder
sourcecode) contains a list of files. Write every line of these files that contain the word
staticinto the file
sed is a very powerful tool to edit text files on the command line. It is often used for search-and-replace operations. As you will see shortly, you can do a simple search-and-replace operation or delete a couple of lines - all of this can be done in many files at once.
You will also see Git Branches in this exercise.
// Author: University of Zurichwith
// Author: ETH Zurichin all files in this directory.
csv-filesdirectory. Remove every odd line from every csv file in this folder.
files with dotscontain a
:). Replace all the
looperis running and
is not runningotherwise. Note that this process is currently not running.
looperif it is not running.
./yourScript.sh looper backGroundshould work.