Letzte Änderung am 2006-08-20 22:55:52 von Richard
Erweiterungen:
Redirection of the output of a command with > or >> to a file
Löschungen:
Redirection of the output of a command with > / >> to a file
Editiert am 2006-08-20 22:55:09 von Richard
Erweiterungen:
$ Command 2>&1 > OutputFromCommand.txt'
The Error output of the command will be saved in the OutputFromCommand.txt" file, and all contents previously in the file will be overwritten.
Löschungen:
$ > Command 2>&1 > OutputFromCommand.txt'
The Error output of the command will be saved in the OutputFromCommand.txt" file, and all contents previously in the file will be overwritten.
Editiert am 2006-08-20 22:54:11 von Richard proofing
Erweiterungen:
$ locate bin | grep aMule
In this example, the command locate bin is invoked, but its output will not be displayed on the screen. Instead it will be forwarded directly to a second command, grep aMule. The forwarded data will serve as input for that second command.
So open a terminal, and open the file with the following command:
$ sudo vi /etc/init.d/bootmisc.sh
and add at the end of it the command or call that will start the program. The sudo command allows a normal user to start certain programs with root privileges, without having to know the password.
$ grep Hello ./HelloWorld.txt
In this example, the word "Hello" will be searched for in the file "HelloWorld.txt". If the text "Hello World" is found in the file, the output will look like this:
There is also the possibility to do a search with specified strings called Regular Expressions?.
$ grep ^Hello ./HelloWorld.txt
grep displays all the lines which start with the word "Hello". This is achieved with the input of the ^ (caret character) at the beginning of the words being searched. With the $ character, you can search all lines where the corresponding string is at the end of the line.
$ grep World$ ./HelloWorld.txt
You can find further help for grep and regexp in the man pages:
Löschungen:
Command1 | Command2
Prompt>locate bin | grep aMule
In this example, the command locate bin is invoked, but its output will not be displayed on the screen. Instead it will be forwarded directly to a second command, grep aMule. The forwarded data will serve as input for that second command.
So open a terminal, and open the file with the following command:
Prompt>sudo vi /etc/init.d/bootmisc.sh
and add at the end of it the command or call that will start the program.
The sudo command allows a normal user to start certain programs with root privileges, without having to know the password.
Prompt>grep Hello ./HelloWorld.txt
In this example, the word "Hello" will be searched for in the file "HelloWorld.txt".
If the text "Hello World" is found in the file, the output will look like this:
Hello World
Prompt>
There is also the possibility to do a search with specified strings called Regular Expressions?.
Prompt>grep ^Hello ./HelloWorld.txt
grep displays all the lines which start with the word "Hello".
This is achieved with the input of the ^ (caret character) at the beginning of the words being searched.
With the $ character, you can search all lines where the corresponding string is at the end of the line.
Prompt>grep World$ ./HelloWorld.txt
You can find further help for grep and regexp in the man pages:
Prompt>man grep
Prompt>man regexp
Editiert am 2006-08-20 22:45:58 von Richard
Erweiterungen:
$ Command 2> ./OutputFromCommand.txt'
The Error output of the command will be saved in the OutputFromCommand.txt" file, and all contents previously in the file will be overwritten.
$ Command 2>>./OutputFromCommand.txt
The Error output of the command will be appended to the OutputFromCommand.txt" file, and all contents previously in the file will not be overwritten.
Löschungen:
Prompt>Command 2> ./OutputFromCommand.txt
The Error output of the command will be saved in the OutputFromCommand.txt" file, and all contents previously in the file will be overwritten.
Prompt>Command 2>>./OutputFromCommand.txt
The Error output of the command will be appended to the OutputFromCommand.txt" file, and all contents previously in the file will not be overwritten.
Editiert am 2006-08-20 22:23:58 von Richard proofing
Erweiterungen:
$ > Command 2>&1 > OutputFromCommand.txt'
The Error output of the command will be saved in the OutputFromCommand.txt" file, and all contents previously in the file will be overwritten.
$ Command 2>&1 >> OutputFromCommand.txt
The Error output of the command will be appended to the OutputFromCommand.txt" file, and all contents previously in the file will not be overwritten.
Löschungen:
Prompt>Command 2>&1 > ./OutputFromCommand.txt
Prompt>Command 2>&1 >>./OutputFromCommand.txt
Editiert am 2006-08-20 21:55:13 von Richard
Löschungen:
$ Command > ResultOfCommand.txt
The Standard output from the Command will be written in the "ResultOfCommand.txt" file, and all the existing data in it will be overwritten.
Editiert am 2006-08-20 21:54:18 von Richard
Erweiterungen:
$ Command > ResultOfCommand.txt
The Standard output from the Command will be written in the "ResultOfCommand.txt" file, and all the existing data in it will be overwritten.
$ Command >> ResultOfCommand.txt
The Standard output from the Command will be appended to the "ResultOfCommand.txt" file, and the existing data in it will not be overwritten.
Löschungen:
Prompt>Command > ./ResultOfCommand.txt
The Standard output from the Command will be written in the "ResultOfCommand.txt" file, and all the existing data in it will be overwritten.
Prompt>Command >> ./ResultOfCommand.txt
The Standard output from the Command will be appended to the "ResultOfCommand.txt" file, and the existing data in it will not be overwritten.
Editiert am 2006-08-20 21:48:05 von Richard proofing
Erweiterungen:
$ Command > ResultOfCommand.txt
The Standard output from the Command will be written in the "ResultOfCommand.txt" file, and all the existing data in it will be overwritten.
Editiert am 2006-08-13 06:15:02 von bluewater (Some keyboards the | symbol is created by "shift and selecting the key \ which has what appears to
Erweiterungen:
(Some keyboards the | symbol is created by "shift and selecting the key \ which has what appears to have two short dashes above the \ )
Editiert am 2006-08-05 04:57:48 von Richard proofing-Richard.
Editiert am 2006-08-05 04:57:06 von Richard
Erweiterungen:
:q ........exit vi (when the file has not been modified)
:q! ......exit, without saving the changes made to the file
:wq ....save the changes, then exit vi (write, quit)
dd ......erase the active line
5dd ...erase the active line and the 4 following ones
x ........erase the active character (like "remove", not like backspace)
r 8 ......substitute the active character with an 8
/mnt ..search for "mnt" (gradual as you type "mnt"). All further "mnt" can be found using "n"
Löschungen:
:q exit vi (when the file has not been modified)
":q! exit, without saving the changes made to the file"
:wq save the changes, then exit vi (write, quit)
dd erase the active line
5dd erase the active line and the 4 following ones
x erase the active character (like "remove", not like backspace)
r 8 substitute the active character with an 8
/mnt search for "mnt" (gradual as you type "mnt"). All further "mnt" can be found using "n"
Editiert am 2006-08-05 04:50:46 von Richard
Erweiterungen:
:q exit vi (when the file has not been modified)
Löschungen:
":q exit vi (when the file has not been modified)"
Editiert am 2006-08-05 04:48:25 von Richard
Erweiterungen:
":q exit vi (when the file has not been modified)"
":q! exit, without saving the changes made to the file"
searched
Löschungen:
:q exit vi (when the file has not been modified)
:q! exit, without saving the changes made to the file
Editiert am 2006-08-05 04:45:31 von Richard
Erweiterungen:
/mnt search for "mnt" (gradual as you type "mnt"). All further "mnt" can be found using "n"
Löschungen:
/mnt search for "mnt" (gradual as you type "mnt").
All further "mnt" can be found using "n"
Editiert am 2006-08-05 04:44:42 von Richard
Erweiterungen:
/mnt search for "mnt" (gradual as you type "mnt").
All further "mnt" can be found using "n"
Löschungen:
/mnt search for "mnt" (gradual as you type "mnt").
- further "mnt" can be found using "n"
Editiert am 2006-08-05 04:43:06 von Richard proofing-Richard.
Erweiterungen:
My favorite editor to tweak configuration files (very practical and it displays syntax in colour). Three modes are available: the viewing mode upon opening the program, the editing mode, and using the ESC key to toggle between modes. The editing mode is to some degree self-explanatory, and in the viewing mode commands are available, such as:
:q exit vi (when the file has not been modified)
:q! exit, without saving the changes made to the file
:wq save the changes, then exit vi (write, quit)
dd erase the active line
5dd erase the active line and the 4 following ones
x erase the active character (like "remove", not like backspace)
r 8 substitute the active character with an 8
/mnt search for "mnt" (gradual as you type "mnt").
- further "mnt" can be found using "n"
I can't tell you much more about vi. When you find yourself with strange results from a bad command, and are not sure how to get out of there, press ESC until you find yourself back in viewing mode.
Löschungen:
My favorite editor to tweak configuration files (very practical and it displays syntax in colour). Three modes are available: the viewing mode upon opening the program, the editing mode, and use the ESC key to go back to toggle between modes. The editing mode is to some degree self-explanatory, and in the viewing mode commands are available, such as:
:q exit vi (when the file has not been modified)
:q! exit, without saving the changes made to the file
:wq save the changes, then exit vi (write, quit)
dd erase the active line
5dd erase the active line and the 4 following ones
x erase the active character (like "remove", not like backspace)
r 8 substitute the active character with an 8
/mnt search for "mnt" (gradual as you type "mnt"). All further "mnt" can be found using "n"
I can't tell you much more about vi. When you find yourself with strange results from a bad command, and are not sure how to get out of there, press ESC until you find yourself back in viewing mode.
Editiert am 2006-08-05 04:36:04 von Richard
Erweiterungen:
This page introduces users with some basics in Linux to
For example: to change from S.u.S.E to Debian .
People in transition from using mouse clicks to using the command line can find a lot of concepts which, possibly, may not be understood in the beginning.
Information found in the forum∞ can always be compared or related to this page.
All programs have the ability to send output to the terminal. That happens, for instance, when they react to an input, when an error occurs, or for actions whose results are sent to a logfile.
They normally do this in one of two ways:
- two consecutive > characters, >>, allows appending the output to an already existing file.
In both cases, the file will be created if it does not exist.
The pipe character can be obtained with the hot-keys "AltGr+<>". The pipe is used to send the output of a command, directly to a second command for additional processing.
In this example, the command locate bin is invoked, but its output will not be displayed on the screen. Instead it will be forwarded directly to a second command, grep aMule. The forwarded data will serve as input for that second command.
Many programs are started every time Kanotix is booted, to do certain things, like linking devices or starting the x-server, to name just a few.
Eventually, you might want to start other programs, as well, at each boot. Editing the /etc/init.d/bootmisc.sh file offers that opportunity.
We often can find files with specific search strings or expressions. grep is used for that purpose.
grep looks through the files with the given string and then displays the corresponding line which contains the string being searched.
This is achieved with the input of the ^ (caret character) at the beginning of the words being searched.
My favorite editor to tweak configuration files (very practical and it displays syntax in colour). Three modes are available: the viewing mode upon opening the program, the editing mode, and use the ESC key to go back to toggle between modes. The editing mode is to some degree self-explanatory, and in the viewing mode commands are available, such as:
Löschungen:
This page introduces users with already some basics in Linux to
for example: to change from S.u.S.E to Debian .
People in transition from using mouse clicks to using the command line can find here a lot of the concepts which may possibly not be understood in the beginning.
Information found in the forum∞ can always be transferred to this page.
All programs have the ability to give an output to the terminal. That happens, for instance, when they react to an input, when an errors occur, or for actions,whose results are sent to a logfile.
They normally do this in two ways:
- two consecutive > characters allow you to append the output to an (already existing) file.
In both cases, the file will be created if not existing already.
The pipe character can be obtained with the hot-keys "AltGr+<>". The pipe is used to send the output of a command to a second command directly to be further processed.
In this example, the command locate bin is invoked, but its output will not be displayed on the screen. Instead it will be forwarded directly to a second command, grep aMule. The forwarded data will work as input for that second command.
Many programs are started every time Kanotix is booted, to do certain things, like linking devices, starting the x-server, etc., to name a few.
Eventually, you might want to start other programs too at each boot. Editing the /etc/init.d/bootmisc.sh file offers that opportunity.
We often can find files with specific search strings or expressions. grep is used to that end.
grep looks through the files with the given string and then displays the corresponding line which contain the seeked string.
This is achieved with the input of the ^ (caret character) at the beginning of the searched words.
My favorite editor to tweak configuration file (very practical, it displays the syntax in colour). Three modes are available: the viewing mode upon opening the program ; the editing mode, and use the ESC key to go back to toggle between modes. The editing mode is to some degree self-explanatory, and in the viewing mode commands are available, such as:
Editiert am 2006-08-01 22:57:53 von zulu9
Erweiterungen:
What you should know to understand the answers in the forums!
And what lies beyond ...
This page introduces users with already some basics in Linux to
concepts they might need to set up and use Kanotix's features.
for example: to change from S.u.S.E to Debian .
People in transition from using mouse clicks to using the command line can find here a lot of the concepts which may possibly not be understood in the beginning.
Information found in the forum∞ can always be transferred to this page.
Redirection of the output of a command with > / >> to a file
All programs have the ability to give an output to the terminal. That happens, for instance, when they react to an input, when an errors occur, or for actions,whose results are sent to a logfile.
They normally do this in two ways:
- Standard output (0)
- Standard error output (2)
The > character is used to redirect the output.
- a > character (over)writes the output in an (existing) file.
- two consecutive > characters allow you to append the output to an (already existing) file.
In both cases, the file will be created if not existing already.
Example 1:
Prompt>Command > ./ResultOfCommand.txt
The Standard output from the Command will be written in the "ResultOfCommand.txt" file, and all the existing data in it will be overwritten.
Example 2:
Prompt>Command >> ./ResultOfCommand.txt
The Standard output from the Command will be appended to the "ResultOfCommand.txt" file, and the existing data in it will not be overwritten.
Redirection of standard error output:
To redirect an error output, you will put the appropriate input (here 2) before the > character, so that only the warning output will be redirected. The standard output will continue to appear on the terminal.
Example 1:
Prompt>Command 2> ./OutputFromCommand.txt
The Error output of the command will be saved in the OutputFromCommand.txt" file, and all contents previously in the file will be overwritten.
Example 2:
Prompt>Command 2>>./OutputFromCommand.txt
The Error output of the command will be appended to the OutputFromCommand.txt" file, and all contents previously in the file will not be overwritten.
Redirection of standard & standard error output:
To redirect both outputs, we use the &1 characters.
Example 1:
Prompt>Command 2>&1 > ./OutputFromCommand.txt
The Error output of the command will be saved in the OutputFromCommand.txt" file, and all contents previously in the file will be overwritten.
Example 2:
Prompt>Command 2>&1 >>./OutputFromCommand.txt
The Error output of the command will be appended to the OutputFromCommand.txt" file, and all contents previously in the file will not be overwritten.
Other options are possible. Consult the man pages of bash or sh.
man bash
The Pipe |
The pipe character can be obtained with the hot-keys "AltGr+<>". The pipe is used to send the output of a command to a second command directly to be further processed.
Command1 | Command2
Example 1:
Prompt>locate bin | grep aMule
In this example, the command locate bin is invoked, but its output will not be displayed on the screen. Instead it will be forwarded directly to a second command, grep aMule. The forwarded data will work as input for that second command.
The output that will be displayed on the screen is the output from the second command, grep aMule. In this case it will only display one line, in which the search string "aMule" occurs.
Commands to run at each boot
Many programs are started every time Kanotix is booted, to do certain things, like linking devices, starting the x-server, etc., to name a few.
Eventually, you might want to start other programs too at each boot. Editing the /etc/init.d/bootmisc.sh file offers that opportunity.
As the file cannot be modified by everybody (otherwise, the hackers would be laughing their heads off), it has to be modified by root.
So open a terminal, and open the file with the following command:
Prompt>sudo vi /etc/init.d/bootmisc.sh
and add at the end of it the command or call that will start the program.
The sudo command allows a normal user to start certain programs with root privileges, without having to know the password.
You also have the possibility, naturally, to login as root.
Searching files with an expression (search string)
We often can find files with specific search strings or expressions. grep is used to that end.
grep looks through the files with the given string and then displays the corresponding line which contain the seeked string.
Example 1:
Prompt>grep Hello ./HelloWorld.txt
In this example, the word "Hello" will be searched for in the file "HelloWorld.txt".
If the text "Hello World" is found in the file, the output will look like this:
Hello World
Prompt>
There is also the possibility to do a search with specified strings called Regular Expressions?.
Example 2:
Prompt>grep ^Hello ./HelloWorld.txt
grep displays all the lines which start with the word "Hello".
This is achieved with the input of the ^ (caret character) at the beginning of the searched words.
With the $ character, you can search all lines where the corresponding string is at the end of the line.
Example 3:
Prompt>grep World$ ./HelloWorld.txt
You can find further help for grep and regexp in the man pages:
Prompt>man grep
Prompt>man regexp
locate - Searching for files
Debian has a very awesome tool named locate.
When a user is looking for a file, he can use the command
locate bin
and obtain in a jiffy a list of all files, whose (full) name, (including its path), contains the search string bin. This speed is only achieved because locate uses a database it creates, and that must be updated every now and then with the command updatedb (as the root user).
Command line text editor: vi
My favorite editor to tweak configuration file (very practical, it displays the syntax in colour). Three modes are available: the viewing mode upon opening the program ; the editing mode, and use the ESC key to go back to toggle between modes. The editing mode is to some degree self-explanatory, and in the viewing mode commands are available, such as:
:q exit vi (when the file has not been modified)
:q! exit, without saving the changes made to the file
:wq save the changes, then exit vi (write, quit)
dd erase the active line
5dd erase the active line and the 4 following ones
x erase the active character (like "remove", not like backspace)
r 8 substitute the active character with an 8
/mnt search for "mnt" (gradual as you type "mnt"). All further "mnt" can be found using "n"
I can't tell you much more about vi. When you find yourself with strange results from a bad command, and are not sure how to get out of there, press ESC until you find yourself back in viewing mode.
Löschungen:
What you should know to understand the answers in the forums!
> And what lies beyond ...
This page introduces users with already some basics in Linux to
concepts they might need to set up and use Kanotix's features.
for example: to change from S.u.S.E to Debian .
People in transition from using mouse clicks to using the command line can find here a lot of the concepts which may possibly not be understood in the beginning.
Information found in the forum
http://forum.kanotix.net∞ can always be transferred to this page.
Redirection of the output of a command with > /
to a file
All programs have the ability to give an output to the terminal. That happens, for instance, when they react to an input, when an errors occur, or for actions,whose results are sent to a logfile.
They normally do this in two ways:
>-Standard output (0)
>-Standard error output (2)
The
> character is used to redirect the output.
>-a
> character (over)writes the output in an (existing) file.
>-two consecutive
> characters allow you to append the output to an (already existing) file.
In both cases, the file will be created if not existing already.
Example 1:
Prompt>Command > ./ResultOfCommand.txt
The
Standard output from the
Command will be written
in the "ResultOfCommand.txt" file, and all the existing data in it will be overwritten.
Example 2:
Prompt>Command >> ./ResultOfCommand.txt
The
Standard output from the
Command will be
appended to the "ResultOfCommand.txt" file, and the existing data in it will
not be overwritten.
Redirection of standard error output:
To redirect an error output, you will put the appropriate input (here 2) before the
> character, so that only the warning output will be redirected. The standard output will continue to appear on the terminal.
Example 1:
Prompt>Command 2> ./OutputFromCommand.txt
The
Error output of the
command will be saved
in the OutputFromCommand.txt" file, and all contents previously in the file will be overwritten.
Example 2:
Prompt>Command 2>>./OutputFromCommand.txt
The
Error output of the
command will be
appended to the OutputFromCommand.txt" file, and all contents previously in the file will
not be overwritten.
Redirection of standard & standard error output:
To redirect both outputs, we use the
&1 characters.
Example 1:
Prompt>Command 2>&1 > ./OutputFromCommand.txt
The
Error output of the
command will be saved
in the OutputFromCommand.txt" file, and all contents previously in the file will be overwritten.
Example 2:
Prompt>Command 2>&1 >>./OutputFromCommand.txt
The
Error output of the
command will be
appended to the OutputFromCommand.txt" file, and all contents previously in the file will
not be overwritten.
Other options are possible. Consult the
man pages of
bash or
sh.
man bash
The Pipe |
The pipe character can be obtained with the hot-keys "
AltGr+
<>". The pipe is used to send the output of a command to a second command directly to be further processed.
Command1 | Command2
Example 1:
Prompt>locate bin | grep aMule
In this example, the command
locate bin is invoked, but its output will not be displayed on the screen. Instead it will be forwarded directly to a second command,
grep aMule. The forwarded data will work as
input for that second command.
The output that will be displayed on the screen is the output from the second command,
grep aMule. In this case it will only display one line, in which the search string
"aMule" occurs.
Commands to run at each boot
Many programs are started every time Kanotix is booted, to do certain things, like linking devices, starting the x-server, etc., to name a few.
Eventually, you might want to start other programs too at each boot. Editing the
/etc/init.d/bootmisc.sh file offers that opportunity.
As the file cannot be modified by everybody (otherwise, the hackers would be laughing their heads off), it has to be modified by root.
So open a terminal, and open the file with the following command:
Prompt>sudo vi /etc/init.d/bootmisc.sh
and add at the end of it the command or call that will start the program.
The
sudo command allows a normal user to start certain programs with
root privileges, without having to know the password.
You also have the possibility, naturally, to login as
root.
Searching files with an expression (search string)
We often can find files with specific search strings or expressions.
grep is used to that end.
grep looks through the files with the given string and then displays the corresponding line which contain the seeked string.
Example 1:
Prompt>grep Hello ./HelloWorld.txt
In this example, the word "Hello" will be searched for in the file "HelloWorld.txt".
If the text "Hello World" is found in the file, the output will look like this:
Hello World
Prompt>
There is also the possibility to do a search with specified strings called
Regular Expressions?.
Example 2:
Prompt>grep ^Hello ./HelloWorld.txt
grep displays all the
lines which start with the word
"Hello".
This is achieved with the input of the
^ (caret character) at the beginning of the searched words.
With the
$ character, you can search all lines where the corresponding string is
at the end of the line.
Example 3:
Prompt>grep World$ ./HelloWorld.txt
You can find further help for
grep and
regexp in the man pages:
Prompt>man grep
Prompt>man regexp
:3:
locate - Searching for files :3:
Debian has a very awesome tool named locate.
When a user is looking for a file, he can use the command
locate bin and obtain in a jiffy a list of all files, whose (full) name, (including its path), contains the search string
bin. This speed is only achieved because
locate uses a database it creates, and that must be updated every now and then with the command
updatedb (as the root user).
:3: Command line text editor:
vi:3:
My favorite editor to tweak configuration file (very practical, it displays the syntax in colour). Three modes are available: the viewing mode upon opening the program ; the editing mode, and use the ESC key to go back to toggle between modes. The editing mode is to some degree self-explanatory, and in the viewing mode commands are available, such as:
:q exit vi (when the file has not been modified)
:q! exit, without saving the changes made to the file
:wq save the changes, then exit vi (write, quit)
dd erase the active line
5dd erase the active line and the 4 following ones
x erase the active character (like "remove",
not like backspace)
r 8 substitute the active character with an 8
/mnt search for "mnt" (gradual as you type "mnt"). All further "mnt" can be found using "n"
I can't tell you much more about vi. When you find yourself with strange results from a bad command, and are not sure how to get out of there, press ESC until you find yourself back in viewing mode.
älteste bekannte Version dieser Seite wurde bearbeitet am 2005-09-09 22:47:55 von Devil28 [ ]
What you should know to understand the answers in the forums!
> And what lies beyond ...
This page introduces users with already some basics in Linux to
concepts they might need to set up and use Kanotix's features.
for example: to change from S.u.S.E to Debian .
People in transition from using mouse clicks to using the command line can find here a lot of the concepts which may possibly not be understood in the beginning.
Information found in the forum
http://forum.kanotix.net∞ can always be transferred to this page.
Redirection of the output of a command with > /
to a file
All programs have the ability to give an output to the terminal. That happens, for instance, when they react to an input, when an errors occur, or for actions,whose results are sent to a logfile.
They normally do this in two ways:
>-Standard output (0)
>-Standard error output (2)
The
> character is used to redirect the output.
>-a
> character (over)writes the output in an (existing) file.
>-two consecutive
> characters allow you to append the output to an (already existing) file.
In both cases, the file will be created if not existing already.
Example 1:
Prompt>Command > ./ResultOfCommand.txt
The
Standard output from the
Command will be written
in the "ResultOfCommand.txt" file, and all the existing data in it will be overwritten.
Example 2:
Prompt>Command >> ./ResultOfCommand.txt
The
Standard output from the
Command will be
appended to the "ResultOfCommand.txt" file, and the existing data in it will
not be overwritten.
Redirection of standard error output:
To redirect an error output, you will put the appropriate input (here 2) before the
> character, so that only the warning output will be redirected. The standard output will continue to appear on the terminal.
Example 1:
Prompt>Command 2> ./OutputFromCommand.txt
The
Error output of the
command will be saved
in the OutputFromCommand.txt" file, and all contents previously in the file will be overwritten.
Example 2:
Prompt>Command 2>>./OutputFromCommand.txt
The
Error output of the
command will be
appended to the OutputFromCommand.txt" file, and all contents previously in the file will
not be overwritten.
Redirection of standard & standard error output:
To redirect both outputs, we use the
&1 characters.
Example 1:
Prompt>Command 2>&1 > ./OutputFromCommand.txt
The
Error output of the
command will be saved
in the OutputFromCommand.txt" file, and all contents previously in the file will be overwritten.
Example 2:
Prompt>Command 2>&1 >>./OutputFromCommand.txt
The
Error output of the
command will be
appended to the OutputFromCommand.txt" file, and all contents previously in the file will
not be overwritten.
Other options are possible. Consult the
man pages of
bash or
sh.
man bash
The Pipe |
The pipe character can be obtained with the hot-keys "
AltGr+
<>". The pipe is used to send the output of a command to a second command directly to be further processed.
Command1 | Command2
Example 1:
Prompt>locate bin | grep aMule
In this example, the command
locate bin is invoked, but its output will not be displayed on the screen. Instead it will be forwarded directly to a second command,
grep aMule. The forwarded data will work as
input for that second command.
The output that will be displayed on the screen is the output from the second command,
grep aMule. In this case it will only display one line, in which the search string
"aMule" occurs.
Commands to run at each boot
Many programs are started every time Kanotix is booted, to do certain things, like linking devices, starting the x-server, etc., to name a few.
Eventually, you might want to start other programs too at each boot. Editing the
/etc/init.d/bootmisc.sh file offers that opportunity.
As the file cannot be modified by everybody (otherwise, the hackers would be laughing their heads off), it has to be modified by root.
So open a terminal, and open the file with the following command:
Prompt>sudo vi /etc/init.d/bootmisc.sh
and add at the end of it the command or call that will start the program.
The
sudo command allows a normal user to start certain programs with
root privileges, without having to know the password.
You also have the possibility, naturally, to login as
root.
Searching files with an expression (search string)
We often can find files with specific search strings or expressions.
grep is used to that end.
grep looks through the files with the given string and then displays the corresponding line which contain the seeked string.
Example 1:
Prompt>grep Hello ./HelloWorld.txt
In this example, the word "Hello" will be searched for in the file "HelloWorld.txt".
If the text "Hello World" is found in the file, the output will look like this:
Hello World
Prompt>
There is also the possibility to do a search with specified strings called
Regular Expressions?.
Example 2:
Prompt>grep ^Hello ./HelloWorld.txt
grep displays all the
lines which start with the word
"Hello".
This is achieved with the input of the
^ (caret character) at the beginning of the searched words.
With the
$ character, you can search all lines where the corresponding string is
at the end of the line.
Example 3:
Prompt>grep World$ ./HelloWorld.txt
You can find further help for
grep and
regexp in the man pages:
Prompt>man grep
Prompt>man regexp
:3:
locate - Searching for files :3:
Debian has a very awesome tool named locate.
When a user is looking for a file, he can use the command
locate bin and obtain in a jiffy a list of all files, whose (full) name, (including its path), contains the search string
bin. This speed is only achieved because
locate uses a database it creates, and that must be updated every now and then with the command
updatedb (as the root user).
:3: Command line text editor:
vi:3:
My favorite editor to tweak configuration file (very practical, it displays the syntax in colour). Three modes are available: the viewing mode upon opening the program ; the editing mode, and use the ESC key to go back to toggle between modes. The editing mode is to some degree self-explanatory, and in the viewing mode commands are available, such as:
:q exit vi (when the file has not been modified)
:q! exit, without saving the changes made to the file
:wq save the changes, then exit vi (write, quit)
dd erase the active line
5dd erase the active line and the 4 following ones
x erase the active character (like "remove",
not like backspace)
r 8 substitute the active character with an 8
/mnt search for "mnt" (gradual as you type "mnt"). All further "mnt" can be found using "n"
I can't tell you much more about vi. When you find yourself with strange results from a bad command, and are not sure how to get out of there, press ESC until you find yourself back in viewing mode.
Letzter Editor :
Eigentümer :