All Questions

Filter by
Sorted by
Tagged with
0
votes
1answer
29 views

Can't seem to concatenate multiple files in different directories

I'm trying to concatenate multiple files together that are in different directories using the following command: ~$ find . -name ‘*.text’ -exec cat {} >> combined.text \; However it doesn't ...
4
votes
1answer
239 views

stdout and stderr redirection to different files

How can I redirect stdout to 2 different files and stderr to another, different file? I want something like <my_cmd> 1> file1 file2 2>file3 I know: <my_cmd> | tee file1 file2 > /...
1
vote
2answers
45 views

Partial Redirection with additional Piping

There's an auto generated file on a remote location that is constantly changing, I can only view the remote file via ssh user@ip cat luckyNumbers it tells me today's lucky numbers and also passes ...
9
votes
1answer
613 views

Redirecting stdout from two programs

I'm running a memory check tool (prog1) on a C++ code (prog2), both of which give me a huge and detailed output. In order to chase down some bugs I need to save this output to a file. I tried ...
0
votes
1answer
627 views

How to redirect output to file to STDOUT?

Similar problem as here How to redirect output from file to stdout? However, the solution given there is not universal. My problem: I have a command that produces output to STDOUT. At the same time, ...
1
vote
2answers
137 views

Awk buffer size

I noticed this interesting set of commands today: $ seq 5 > alfa.txt $ awk '{print 6 > ARGV[1]} 1' alfa.txt 1 2 3 4 5 $ cat alfa.txt 6 6 6 6 6 My first question was why am I getting several 6 ...
2
votes
2answers
101 views

bash echo the command line executed at the command line itself (not in a script)

For documentation purposes, I mean to redirect to file stdout and stderr from a command I execute. For instance, I would run (my command is less trivial than the alias ll but it probably doesn't ...
27
votes
2answers
2k views

Why is `sort < “$f1” ` preferred over `sort — “$f1”`, and why is this preferred over `sort “$f1”`?

From https://unix.stackexchange.com/a/458074/674 Remember to use -- when passing arbitrary arguments to commands (or use redirections where possible). So sort -- "$f1" or better sort < "$f1" ...
0
votes
1answer
56 views

How can I use a file in a command and redirect output to the same file without truncating it? [duplicate]

cat package.yaml > package.yaml The above will truncate package.yaml, and hence the file will be empty - cat will have empty output. How can I avoid truncating the file? Is there an alternative ...
1
vote
1answer
688 views

Get first N lines of output from a pipe operation

I'm using a piped command to migrate a big production DB from one host to another using this command: mysqldump <someparams> | pv | mysql <someparams> And I need to extract the line 23 (...
1
vote
1answer
1k views

How to redirect stdin and stdout and stderr at the same time in bash? [duplicate]

I want to redirect stdin and stdout and stderr at the same time in bash, is this how it's done: someProgram < stdinFile.txt > stdoutFile.txt 2> stderrFile.txt
3
votes
3answers
6k views

pipe password to `sudo` and other data to `sudo`ed command

Both of these commands work: (note the -S in sudo tells sudo to read the password from stdin). echo 'mypassword' | sudo -S tee -a /etc/test.txt &> /dev/null echo -e '\nsome\nmore\ntext' | sudo ...
1
vote
1answer
51 views

What is the state of the standard I/O stream while issuing a command?

I'm new to linux about ten days, and my English is not good. I'm learning the I/O redirection part. I know when a command is successful, the screen do not display error message, and the command ...
1
vote
3answers
37 views

How to make the redirect file have a custom order

This is my test .sh file. errorandoutput.sh #!/bin/bash echo myecho ls dflj If I run ./errorandoutput.sh >file 2>&1,then we can get such file But I hope the STDOUT information is after ...
1
vote
0answers
498 views

How can I send stdout to multiple commands in fish shell?

Same question as How can I send stdout to multiple commands? but for fish shell.
0
votes
1answer
778 views

Exclude parameter in du command

I found somehow interesting command do specify disk usage which I am using without actually knowing what does the exclude pattern do. Instead excluding some locations or file names or just globs, the ...
2
votes
2answers
66 views

Why doesn't wget url/mediafile.ext > medafile2.ext work?

I tried the following : [$] wget http://cdn.edgecast.steamstatic.com/steam/apps/256679148/movie480.webm > Conan1.webm [1:21:05] --2017-02-23 01:...
2
votes
1answer
5k views

How to use pipe to apply a text to a program

My instructor says to use a pipe to apply a text file, which consists a list of test cases, to a working program that takes test case from the input file. Say i have test_cases.txt my_program //my ...
14
votes
3answers
2k views

In the code “{ exec >/dev/null; } >/dev/null” what is happening under the hood?

When you redirect a command list that contains an exec redirection, the exec >/dev/null doesn't seem to still be applied afterwards, such as with: { exec >/dev/null; } >/dev/null; echo "Hi" "...
1
vote
1answer
240 views

How to prevent octal dump (od) returning?

I am trying to read some output from /dev/ttyUSB0, using od on Ubuntu. So I used this command: od -x --endian=big < /dev/ttyUSB0 When I used it yesterday it was not blocking and just showed stuff ...
22
votes
2answers
3k views

cat gives different error when opening non-existing file

Both of the following commands try to open a non-existing file foo, but the error messages are a little different. What could be the reason? $ cat foo cat: cannot open foo $ cat < foo -bash: foo: ...
1
vote
1answer
701 views

How to send standard input through a pipe

I need to send a standard input or a keycode right after the program starts. For example $ program | F3
1
vote
1answer
64 views

How to save a program's running history to a file?

I'm running a program called gatk-picard.sh and it's printing out the running history/log (INFO rows below). Since the program will take about 20 hours to finisn and I wanted to put it on running when ...
4
votes
5answers
11k views

When I redirect the output of ls to a file, the filename is included in that file. How can I avoid this?

Observe: $ ls $ ls > list $ cat list list This appears to indicate that when ls is executed that the redirection into file list has already begun and the list file is already created. A fine ...
2
votes
1answer
1k views

Capture all output, error, warning and their appearance order of linux's command

In linux we can redirect stdout and stderr or both of them to files. For example: Redirect stdout and stderr to two files: command 1>out 2>err. By this way, we can separate output and error in ...
0
votes
1answer
147 views

“time > time.txt” refuses to work propely

I just started learning Linux commands. I was experimenting with the > command, that, as far as I understand, makes the command before it write it's output to the file after the sign. My perception ...
4
votes
1answer
1k views

How to read from stdin in process substitution? [duplicate]

I would like to send stdout to multiple commands, however I'm not sure how do I read from standard input within process substitution? My attempts: $ echo foo >(cat /dev/stdin) >(cat /dev/stdin)...
11
votes
2answers
6k views

How to redirect the output of a command to an already existing file without deleting its contents? [duplicate]

I am making a backup of some files and am creating a checksum file, checksums.txt, to later check the integrity of my data. However pasting each checksum manually into the file is inconvenient since ...
9
votes
3answers
3k views

Command redirection to multiple files: command >file1 >file2 [duplicate]

I have this command: cat somefile >file1 >file2 After I executed this command I can't figure out why file1 has nothing in it. It should have the output of the first file (somefile), but ...
11
votes
2answers
9k views

sponge from moreutils - what's the difference to shell redirect? useful examples?

> brew install moreutils ==> Downloading https://homebrew.bintray.com/bottles/moreutils-0.55.yosemite.bottle.tar.gz #################...
1
vote
3answers
411 views

pipe in shell with redirection

My understanding is that a pipe in shell like a | b redirects b's stdin to a's stdout. However, I tried ls | less < somefile, the behavior is very strange. less shows the output of ls concatenated ...
2
votes
1answer
4k views

awk with variables in condition and in output redirection file

I would please like some help with this command because I didn't find anything in documentation that can cover everything I want. I have some variables that are global, so I would prefer to keep them ...
3
votes
1answer
4k views

How can I redirect output files to a specific directory/folder

Suppose I have an executable in Unix. Suppose the name of the .exe file is myExe and it takes two parameters. I did not create this executable, this is a freely available one. myExe generates 4 ...
8
votes
6answers
35k views

Awk - output the second line of a number of .dat files to one file

I have multiple files something like: (in reality i have 80) file1.dat 2 5 6 9 7 1 file2.dat 3 7 8 4 1 3 I want to end up with a file containing all of the second lines. i.e. output.dat 6 9 ...
21
votes
6answers
2k views

Is there another simple way to append line to end of file other than `>>`?

Recently I'm echoing short sentences to a tree_hole file. I was using echo 'something' >> tree_hole to do this job. But I was always worried of what if I mis-input of > instead of >>, ...
1
vote
1answer
417 views

Output Redirection

I am using the tee command to output the compilation errors of a program into a file along with the terminal. gcc hello.c | tee file.txt This is the command I have used. The compilation errors are ...
9
votes
3answers
14k views

grep: input file 'X' is also the output

I use ubuntu 14.4, and attempt to redirect the output of grep command to a file, but I keep getting this error: grep: input file 'X' is also the output I've searched for this issue and just found ...
1
vote
1answer
1k views

Redirect output to stdout and pipe to a binary

I have a nice PS1 line in my .bash_profile, and I want to copy it to another machine. So I want to view it AND copy it to my clipboard. I can't figure out how to string the commands to do this ...
2
votes
1answer
3k views

How do I Nohup an interactive shell-script?

My Script is having 2 command-line arguments and then just couple of questions, after these questions the script will run for itself, I'm able to pass the command-line argument by just doing, -bash-3....
7
votes
3answers
674 views

Combining brace expansion and output redirection

Often, I use parameter expansion on the command-line, such as cp a.{ext1,ext2} which is expands to cp a.ext1 a.ext2 However, in many cases I do not use cp, but another tool, let's call it cat, and ...
4
votes
1answer
340 views

How does SSH display the message “The authenticity of host .. can't be established”?

I wanted to trace down the system call used by ssh to output this warning message: > ssh root@abcde The authenticity of host .. can't be established. If the message were sent to stderr or stdout, ...
2
votes
1answer
668 views

fg a bg process because you forgot to redirect output to /dev/null

I did Ctrl+Z bg with the intention of disowning next, but I forgot to redirect, now I cant get to my terminal because the scrolling of the output (tarballed a huge directory with verbose set). How do ...
47
votes
1answer
126k views

What does 2>&1 in this command mean? [duplicate]

I understand that this command attempts to write to nowhere or a null device but what does 2>&1 mean here? wget -q -O - http://yourwebsite.com/wp-cron.php?doing_wp_cron > /dev/null 2>&...
22
votes
1answer
65k views

Always redirect error to /dev/null

I know I can redirect the error messages from a command to /dev/null using the following syntax: command arg1 arg2 2>/dev/null But is there a way to do this by default so that the error messages ...
1
vote
2answers
869 views

Chaining mysqldumps commands to output a single gzipped file

Let's say I have these series of commands mysqldump --opt --databases $dbname1 --host=$dbhost1 --user=$dbuser1 --password=$dbpass1 mysqldump --opt --databases $dbname2 --host=$dbhost1 --user=$dbuser1 ...
10
votes
3answers
1k views

How to `locate` multiple files and open them in vim?

Suppose that I have a file named filename123.txt and it is the single file that is named so, and I can locate it with the command locate filename123. And it returns only this file. Now I want to open ...
27
votes
3answers
5k views

Order of redirections

I don't quite understand how the computer reads this command. cat file1 file2 1> file.txt 2>&1 If I understand, 2>&1 simply redirect Standard Error to Standard Output. By that ...
10
votes
3answers
27k views

stderr redirection not working in csh

I run the following command: pkg_add emacs-23.4,2.tbz 2> output.log The output still displays in the terminal. When I press ↑, I get pkg_add emacs-23.4,2.tbz 2 > output.log with a space ...
178
votes
8answers
128k views

How can I send stdout to multiple commands?

There are some commands which filter or act on input, and then pass it along as output, I think usually to stdout - but some commands will just take the stdin and do whatever they do with it, and ...
11
votes
2answers
13k views

the usage of < /dev/null & in the command line

I tried to run an example java program using the following command line. However, I do not know what is the trailing part < /dev/null & used for? java -cp /home/weka.jar weka.classifiers....