Skip to main content

Questions tagged [output]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
231 votes
7 answers
638k views

Pass the output of previous command to next as an argument

I've a command that outputs data to stdout (command1 -p=aaa -v=bbb -i=4). The output line can have the following value: rate (10%) - name: value - 10Kbps I want to grep that output in order to store ...
Paul's user avatar
  • 2,311
112 votes
5 answers
363k views

Save all the terminal output to a file

Is there some way of saving all the terminal output to a file with a command? I'm not talking about redirection command > file.txt Not the history history > file.txt, I need the full terminal ...
user avatar
72 votes
4 answers
243k views

how to output text to both screen and file inside a shell script?

Currently I have a shell script which logs messages to a log file like this: log_file="/some/dir/log_file.log" echo "some text" >> $log_file do_some_command echo "more text" >> $log_file ...
jurchiks's user avatar
  • 823
23 votes
2 answers
5k views

What prevents stdout/stderr from interleaving?

Say I run some processes: #!/usr/bin/env bash foo & bar & baz & wait; I run the above script like so: foobarbaz | cat as far as I can tell, when any of the processes write to stdout/...
Alexander Mills's user avatar
1 vote
2 answers
1k views

Output colored text in all major distros without using non-word color codes (like \033[0;31m)

I found these ways, for example, to output colored text in a simple way to the screen: RED="\033[0;31m" # Red color (via ANSI escape code); NC='\033[0m' # No color (via ANSI escape code); echo -e "${...
user avatar
41 votes
6 answers
65k views

How do I add newlines between lines printed on the command line?

Mail logs are incredibly difficult to read. How could I output a blank line between each line printed on the command line? For example, say I'm grep-ing the log. That way, multiple wrapped lines aren'...
xenoterracide's user avatar
15 votes
3 answers
17k views

How to redirect the output of any command?

I'm trying to write a simple script to monitor my network status, without all of ping's output: ping -q -c 1 google.com > /dev/null && echo online || echo offline The problem is that when ...
operalala's user avatar
  • 371
26 votes
3 answers
112k views

Capture all the output of a script to a file (from the script itself) [duplicate]

I have a bash script that calls various commands and prints some output (both from the called commands themselves, such as git pull, and informative messages generated by the script itself such as ...
Dr. Gianluigi Zane Zanettini's user avatar
24 votes
5 answers
26k views

Pipe the output of a command if it is successful

INPUT_FILE=`ls -rt $MY_DIR/FILE.*.xml | head -1 | xargs basename` I wanted to execute the second command (head -1) only if the first command is successful. How do I improve this command?
Govind Kailas's user avatar
18 votes
3 answers
24k views

Where does the output of `at` and `cron` jobs go?

Where does standard output from at and cron tasks go, given there is no screen to display to? It's not appearing in the directory the jobs were started from, nor in my home directory. How could I ...
Michael Durrant's user avatar
11 votes
1 answer
10k views

redirecting output of running background job in bash

in bash I have some jobs running, in background. They are always producing random irrelevant error messages that pollute the terminal. I am not always so prompt to start them with the 2>&1 > ...
fstab's user avatar
  • 900
11 votes
3 answers
3k views

Keep terminal input line at the top of the terminal?

It's really hard to explain what I am looking for exactly so I have made some example output of how I would like my terminal to behave. (each number at the start of a line represents a return on that ...
Ian's user avatar
  • 211
9 votes
2 answers
13k views

Log output of GNU screen in real time?

I'm trying to get the output of a GNU Screen to a log file in real time. I've tried using tee, but that appears to not work with screen. The log function for screen will not work for this as it is not ...
VoidWhisperer's user avatar
8 votes
2 answers
3k views

double grep on tail -f gives no output

If I follow a file somehow like this: tail -f /var/log/syslog|grep s I see all lines containing an "s" Why does this not give any output, if I grep it again to the same "s"? tail -f /var/log/...
rubo77's user avatar
  • 29.6k
6 votes
1 answer
11k views

Evaluating the return value of a command line

How do I evaluate or calculate the return value of a command line? For exemple, I count the number of lines with a grep and I want to know if that value is above X. If so, I want to print the number ...
Philippe Carriere's user avatar
4 votes
2 answers
22k views

How can I get vsftpd version into shell variable?

I want to get vsftpd version into shell variable. I can get it to console with ease: # vsftpd -version vsftpd: version 2.2.2 Also I can get a lot of other info into variable: # i=`bash --version 2&...
Putnik's user avatar
  • 886
3 votes
2 answers
23k views

Get the output from expect script in a variable

I have an expect script which provides the IP address: #!/bin/expect -f set nodename [lindex $argv 0] spawn virsh console $nodename expect "Escape character is" send "\n" expect "localhost login: " { ...
karan ratnaparkhi's user avatar
3 votes
1 answer
454 views

Why is shell treating a part of the output of $(<file) as a command?

I saw this line while reading a blog on IFS that is : for i in $(<test.txt) And thought that $(<test.txt) prints the file contents to STDOUT. I maybe wrong in this, but out of curiosity I ...
C0deDaedalus's user avatar
1 vote
2 answers
6k views

Redirect grep error output to file

I wanted to capture to a file the errors being returned on the command line from grep. For example, grep foo.lookup No such file in directory I want to output that to a log file. This is my shell ...
user60216's user avatar
  • 325
1 vote
4 answers
370 views

Shell command to put recent line of output onto current command line

Shells have a useful feature where pressing the keyboard UP arrow replaces the contents of the current command line with the previous command that was entered. (And if you do it again, the command ...
HighCommander4's user avatar
-3 votes
2 answers
1k views

What is the utility of piping to `/dev/null`?

Seeing that /dev/null's utility isn't immediately obvious to me, what is the use of /dev/null piping?
Suppressing Output's user avatar
85 votes
10 answers
61k views

Converting colored output into html

There are tools providing coloured output: dwdiff -c File1 File2 # word level diff grep --color=always # we all know this guy ... The question is: How to convert their colored output of arbitrary ...
Grzegorz Wierzowiecki's user avatar
23 votes
3 answers
3k views

How to prevent random console output from breaking the terminal?

There are many questions on SE that show how to recover from terminal broken by cat /dev/urandom. For those that are unfamiliar with this issue - here what it is about: You execute cat /dev/urandom ...
rr-'s user avatar
  • 983
21 votes
4 answers
25k views

Why does this 'at' command not print to the standard output?

I am a relative Linux novice. I am trying to learn how to use at so that I can schedule tasks to begin at a later time, without using sleep. I have been looking at this previous question for help. ...
Andrew's user avatar
  • 17.2k
17 votes
3 answers
37k views

Suppress 'file truncated' messages when using tail

I'm tailing a log file using tail -f messages.log and this is part of the output: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce eget tellus sit amet odio porttitor rhoncus. Donec ...
Bas Peeters's user avatar
17 votes
1 answer
11k views

Show only graph in htop output

Would it be possible to show only the summary section of htop output? desired look: I have looked into the manpages but couldn't find any options to do so. The closest thing i have found is this: ...
Ashesh's user avatar
  • 393
14 votes
5 answers
46k views

How do I get (only) the http status of a site in a shell script?

I figure curl would do the job. I wrote in a script: #!/bin/sh function test { res=`curl -I $1 | grep HTTP/1.1 | awk {'print $2'}` if [ $res -ne 200 ] then echo "Error $res on $1"...
user avatar
14 votes
6 answers
121k views

How can I output the difference between 2 files?

My file consists of the the following; roughly: username:username:username:username:username The above line continues to about 600 characters. I use the awk command in order to use it as an ...
Ben's user avatar
  • 315
10 votes
4 answers
865 views

Save output of command that modifies environment into a variable

How to save output of a command that modifies environment into a variable? I'm using bash shell. Assume that I have: function f () { a=3; b=4 ; echo "`date`: $a $b"; } And now, I can use commands ...
faramir's user avatar
  • 215
7 votes
4 answers
2k views

Output current day using cal

I'm asked to output the current day using the cal command. So far, I discovered that before the current date there is a _ symbol. I decided to use grep here: cal | grep '\b_*', but it outputs the ...
Welez's user avatar
  • 181
7 votes
1 answer
11k views

Why can't an input file be an output file?

Specifically in the case of cat x y > y and cat x >> x where x and y are files. What would happen if I didn't get a "input file is output file" error? Basically, why am I not allowed to run ...
Rabbit's user avatar
  • 71
5 votes
1 answer
3k views

Why does grep change the length of output lines?

I often use dpkg or aptitude combined with grep when I want to list certain packages available or installed on my system, but I noticed that when I add | grep, the output lines look a little bit ...
Mikhail Morfikov's user avatar
5 votes
4 answers
28k views

Changing audio output from terminal

I have a Xonar DGX card, and I can change the audio output with alsamixer by going to the Analog Output option and switching between Stereo Headphones and Stereo Headphones FP. How can I do the same ...
Javier Garcia's user avatar
4 votes
1 answer
13k views

How to disable VLC output in command-line mode?

When I play music on vlc or cvlc in terminal or console there is always this (shown below) non-stopping output that prevents me from issuing commands by pressing ENTER key. I want to disable it, I ...
easl's user avatar
  • 2,038
4 votes
2 answers
2k views

Limit stdout from a continuously running process

I haven't had much luck finding an answer to my problem, but maybe I'm not asking for it correctly. I have a process I startup like the following: nohup ping 127.0.0.1 > log.txt >2>&1 & ...
eproms's user avatar
  • 43
3 votes
2 answers
6k views

Redirect Output of Pocketsphinx_continuous to a file

I have an ugly command: pocketsphinx_continuous -samprate 48000 -nfft 2048 -hmm /usr/local/share/pocketsphinx/model/en-us/en-us -lm 9745.lm -dict 9745.dic -inmic yes Breakdown: It listens for any ...
Patrick Cook's user avatar
3 votes
4 answers
6k views

Leave remote command running storing output

Scenario; I have SSH'ed to a machine, opened a new screen session, and fired off a script. Some days later I SSH back to that machine, re-attach the screen session and look at the output that has ...
Baldrick's user avatar
  • 7,782
3 votes
1 answer
2k views

Get the output of the time command

I have the following command time compare -metric rmse -subimage-search -dissimilarity-threshold 1 -similarity-threshold 0.99 $page \( -size 1x1 xc:black \) null: which produces the following ...
user68650's user avatar
  • 343
2 votes
1 answer
6k views

Pipe output from one command to another command's non standard input [duplicate]

I would like to do something similar to the following: which someapplciation | cd outputfrompreviouscommand The command which provides a directory and I would like to be able to make that output my ...
Avlaxis's user avatar
  • 23
2 votes
2 answers
222 views

How do I echo a line with linebreak at the end at window border? [duplicate]

I would like to echo a list all in one line, TAB separated (like ls does with files in one folder) for i in one two some_are_very_long_stuff b c; do echo $i; done will print one line per word: one ...
rubo77's user avatar
  • 29.6k
2 votes
1 answer
9k views

how do i redirect output from tailf & grep to a file [duplicate]

All I wanted is to grep for specific lines in an ongoing log and re-direct it to some file.. tailf log | grep "some words" Now, I want the above command output to get re-directed to some file in on-...
Gokul's user avatar
  • 1,071
2 votes
1 answer
581 views

Sending `time` command into text file [duplicate]

I want to get the result of time command into a text file but it's not working it only put blank space in the text file. I already tried this commands, A- $ x=`time` $ echo $x > log.txt $ cat ...
Edmhar's user avatar
  • 395
1 vote
2 answers
2k views

Do all Linux processes write EOF to stdout when they are terminating/have finished terminating?

I'm having trouble with sending shutdown -h 0 to a lxc Debian container (i.e. executing this command in the lxc) with with the python pexpect module (in a python script). In this module the user can "...
Kalle Richter's user avatar
1 vote
2 answers
1k views

Echo calculation to text file [duplicate]

I am working on a project to calculate my overtime at work with a shell script. I have two inputs and want to find if my number is over 800 = 8 hours; if it is bigger, then it has to print out the ...
peter's user avatar
  • 17
0 votes
3 answers
9k views

sudo iwlist wlan0 scan | grep ESSID > essid.txt (How do I export without the word ESSID in txt file)

So my goal is to answer my other question I am working on. Which is Connect to Open Wifi. Currently I am getting close, as I know there is only one Wifi connection, I would like to export the results ...
FreeSoftwareServers's user avatar
-1 votes
1 answer
83 views

Why output is on the prompt line?

$ echo 'hello world' > >(wc) $ 1 2 12 █ Why output is on the prompt line and not in the separate line below? Also why expects input at the end? Since, the command below works fine ...
Prakash Bhattarai's user avatar