Following keyboard shortcuts are very useful while working in Bash
So stderr goes to the stdout and that goes to the file.
- Ctrl +u Cut the current line
- Ctrl+y Paste the line which has been earlier with Ctrl +u
- Ctrl +l clear the screen
- Ctrl+G get the new line and abandon the current line
- Ctrl+a go to beginning of the line
- Ctrl+e go to End of line
- Ctrl+k Erase from the cursor to the end of line
- Ctrl +r search in the history
- Ctrl+w cuts a word backwards
- Ctrl+d Tired of typing 'exit' to close a terminal? Just hit ctrl+d on a blank line and boom!
- Ctrl+right - Jump one word to the right.
- Ctrl+left - Jump one word to the left.
- ALT+DEL Delete word(s) to the left of the cursor
- !! Repeat last command
some_command | tee output.txtif you want to redirect both STDERR(2) and STDOUT(1) to the same thing then we can use 2 >&1
some_command >big_blob_of_crap.txt 2>&1The output of the ‘come_command’ is redirected to a ‘big_blob_of_crap.txt’ and the error channel (that is the ’2′ is redirected to a pointer (?) of the output (‘&1′).
So stderr goes to the stdout and that goes to the file.
some_command &>big_blob_of_crap.txtIf you want to redirect STDERR and STDOUT to a single file and at the same time, you want to view them on the screen then we can use use
some_command |tee big_blob_of_crap.txt 2>&1
3 comments:
I recently discovered the ^R search command. I now use it all the time. Use escape to cancel and enter to execute the command.
Here are some other history commands I use a lot:
!! Repeat last command.
!foo Repeat last command starting with "foo".
!?foo Repeat last command ending with "foo".
!?foo? Repeat last command containing "foo".
^foo^bar Replace "foo" with "bar" in the last command.
Thanks Ray. I am updating the doc with your info so that we can find all useful shortcuts in one place.
Post a Comment