This is the third way to do arithmetic operations. First we looked at 'let' and 'expr' commands.
Now we use $ sign with two brackets.
example1:
echo $(( 5 * 6))
example2:
echo $(($((4 * 5)) + 300 ))
Tuesday, August 19, 2008
Monday, August 18, 2008
Redirect the standard error
There are three I/O streams available in Unix.
1. STDIN (0)
2. STDOUT (1)
3. STDERR (2)
To redirect the error to a file
ls -l doesnotexist 2>err.txt
Example:
ls -l exp 1>result.txt 2>error.txt
This command outputs the standard output into the file called result.txt and the standard error to the file called error.txt.
1. STDIN (0)
2. STDOUT (1)
3. STDERR (2)
To redirect the error to a file
ls -l doesnotexist 2>err.txt
Example:
ls -l exp 1>result.txt 2>error.txt
This command outputs the standard output into the file called result.txt and the standard error to the file called error.txt.
Redirection
To redirect the output to a file use '>' command
example :
ls -l > example.txt
'>' command replace the existing content of the file. If you want to append the output to with existing content, use '>>'
example:
ls -l >> example.txt
'<' command use to get the input from a file.
example:
cat < example.txt
This redirection command doesn't know where is the input come from.
For example if you use
wc -w < example.txt
It only outputs the number of words in the file.
If you use wc -w example.txt instead of that you will get the number of words and the name of the file.
example :
ls -l > example.txt
'>' command replace the existing content of the file. If you want to append the output to with existing content, use '>>'
example:
ls -l >> example.txt
'<' command use to get the input from a file.
example:
cat < example.txt
This redirection command doesn't know where is the input come from.
For example if you use
wc -w < example.txt
It only outputs the number of words in the file.
If you use wc -w example.txt instead of that you will get the number of words and the name of the file.
Subscribe to:
Posts (Atom)