| Keystroke | Action |
|---|---|
| CTRL-B | Move the cursor left |
| CTRL-F | Move the cursor right |
| CTRL-P | View the previous command (or move the cursor up) |
| CTRL-N | View the next command (or move the cursor down) |
| CTRL-A | Move the cursor to the beginning of the line |
| CTRL-E | Move the cursor to the end of the line |
| CTRL-W | Erase the preceding word |
| CTRL-U | Erase from cursor to beginning of line |
| CTRL-K | Erase from cursor to end of line |
| CTRL-Y | Paste erased text (for example, from CTRL-U) |
You can redirect stderr
$ ls /fffff > file 2> error_fileThe number 2 specifies the stream ID that the shell modifies. Stream ID 1 is standard output (the default), and 2 is standard error.
Redirect to the same file
$ ls /fffff > file 2>&1Newer shortcut to 2>&1 in bash
$ ls -l /bin/usr &> ls-output.txt
$ ls -l /bin/usr &>> ls-output.txtTo channel a file to a program's standard input, use the < operator:
$ head < /proc/cpuinfohead -n [int]tail -n [int]With
--follow(-f), tail defaults to following the file descriptor, which means that even if a tail'ed file is renamed, tail will continue to track its end. This default behavior is not desirable when you really want to track the actual name of the file, not the file descriptor (e.g., log rotation). Use--follow=namein that case. That causes tail to track the named file in a way that accommodates renaming, removal and creation.
tail -f [file]
-Fsame as--follow=name --retry. Ideally used when you want to track/retry the actual name of the file, not the file descriptor (e.g., log rotation)
tail -F [file]grep -C [int] [search]cat $(find . -type f -print) | wc -l