Linux2
Leveraging the power of the Linux command line
Getting the content for this practical
The necessary files for this practical are hosted in a version control system. To obtain them, just type the following command:
$ svn export http://source.ggy.bris.ac.uk/subversion-open/linux2/trunk linux2
This will fetch all necessary files and put them in a folder called linux2/. Ignore the cryptic syntax so far, an introduction to version control using subversion (svn) will be given later on.
Output redirection
In the Linux1 practical, we have discovered a few Linux commands. Some of these commands use input from the keyboard (standard input) and output data to the screen (standard output). It is possible to (a) redirect input and output and (b) link commands together to perform complex actions.
Redirecting standard input and output
The diff command outputs to the screen.
$ diff file1 file2 > diff.txt
$ diff file2 file3 > diff.txt $ diff file2 file3 >> diff.txt
It is also possible to redirect the input. For instance consider the following
Pipelines
pipes between simple commands
ls -l | more
diff file1 file2 | tail
grep -i scene | wc
Automating things
"batch files"
Launching, monitoring and controlling jobs
Background, bg, jobs, fg, nohup, top, kill
Shell Scripting
Environment Variables
SHELL PWD PATH (LD_LIBRARY_PATH)
Uploaded example scripts for:
- Environment Variables
- Conditionals
- For loops
- Functions
- Arithmetic
Text Processing
sed, awk.