Capture both output streams
Send stdout and stderr to a file and to the screen at the same time.
command 2>&1 | tee /tmp/all.log
More linux commands
-
grep -rl 'old_string' /etc/ | xargs sed -i 's/old_string/new_string/g'Find files that contain the text and replace it directly in them.
-
awk '{print $1, $3}' /etc/passwdPrint the 1st and 3rd fields of each line. By default awk splits on spaces, so for /etc/passwd you need -F: to split on colons.
-
awk '{sum += $2} END {print sum}' file.txtAdd up the values in column 2 of a text file.
-
sed -i '/^#/d' config.confDelete all comment lines that start with # directly in the file.
-
sed -n '/START/,/END/p' file.txtPrint the block of text from START to END, including the marker lines.