Linked Questions

655
votes
7answers
1.6m views

How do I save terminal output to a file?

How do I save the output of a command to a file? Is there a way without using any software? I would like to know how.
0
votes
1answer
400 views

Continuous terminal output to a file [duplicate]

I am running a software which keeps on printing the steps followed and progress of it on the terminal. I would like to redirect the output from terminal to log file as and when the software prints ...
0
votes
1answer
150 views

Cannot duplicate all ouput to a file with tar/pigz [duplicate]

I'm using in my script: tar cfh - "$SRC_DIR" --exclude-from <(find $SRC_DIR -size +$EXCLUDE_MB_FILES) | pigz -9 --quiet --keep --recursive --rsyncable > $BACKUP_TARGER_DIR/$ARC_NAME | tee $...
1
vote
0answers
48 views

How can I get an error report when I execute a command in Ubuntu server? (Backup on PostgreSQL) [duplicate]

I have to do a backup of a (heavy) PostgreSQL database in Ubuntu Server and I want to make sure that I don't have any fails. The command is: pg_dump database_name -h localhost -p port_number >&...
0
votes
0answers
42 views

Saving command error log into text file [duplicate]

I would like to know whether is it possible to save an error log string of a bad executed command into a text file. for example.. if I type cp textfile and destination folder...and the log says “...
1
vote
0answers
36 views

how to print for multiple files differently? [duplicate]

Give a single command line for searching a file ‘datafile’ for the string “Internet”, sending the output of the command to a file called ‘Internet.freq’ and any error message to a file ‘error.log’. ...
195
votes
8answers
95k views

What is the difference between “Redirection” and “Pipe”?

This question may sound a bit stupid, but I can not really see the difference between redirection and pipes. Redirection is used to redirect the stdout/stdin/stderr, e.g. ls > log.txt. Pipes are ...
18
votes
6answers
31k views

How to get dialog box input directed to a variable?

I have been teaching myself bash scripting and have run into an issue. I have written a script to take input from the user, using the 'read' command, and make that input a variable to use later in the ...
28
votes
4answers
25k views

What is the differences between &> and 2>&1

There are two forms of redirection the standard output and standard error into standard output. But which one is better? and why the &> is considered the perfect? I can't find what is the ...
15
votes
3answers
1k views

What does & mean exactly in output redirection?

I see stuff like command 1> out or with 2>&1 to redirect stderr, but sometimes I also see &> by itself, etc. What is the best way to understand & and what it means exactly?
3
votes
1answer
791 views

What does “exec 1>/var/opt/log/my_logs/MYPROG_`date '+%Y%m%d_%H%M%S'`.log 2>&1” do?

I'm trying to understand what the below piece of shell script is doing. I know that exec without any arguments redirect the output of the current shell but am not able to understand what the below ...
2
votes
3answers
389 views

How to insert a line break between stderr and stdout

This question helped me understand how to combine stderr and stdout: How to redirect stderr to a file with this command: gunzip -vc /opt/minecraft/wonders/logs/20* 2>&1 But how may one ...
0
votes
2answers
523 views

bash - return and print statement

I have a bash function that returns a number by adding 20 to it. At the same time, I would like to display to see what is the input. function add_nos { echo "$1" echo $(($1 + 20)) return ...
1
vote
0answers
684 views

nvidia overclock on startup running a .sh script in rc.local not working

Good afternoon. I am having issues getting a startup script i wrote for my overclock settings to initialize on bootup. I have run the script independently and it works perfectly; however, when i run ...
2
votes
1answer
255 views

how input redirection works?

On my understanding, any command that reads from standard input (i.e keyboard), that it gets its input from a file. $echo < text_content.txt $ But echo command does not read and display the ...