We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [redirect]

Redirection is the switching of a standard stream of data so that it comes from a source other than its default source or so that it goes to some destination other than its default destination.

Filter by
Sorted by
Tagged with
106
votes
4answers
56k views

What's the difference between <<, <<< and < < in bash?

What's the difference between <<, <<< and < < in bash?
209
votes
8answers
100k 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 ...
247
votes
4answers
435k views

What does 2>/dev/null mean?

I would like a brief explanation of the following command line: grep -i 'abc' content 2>/dev/null
329
votes
2answers
601k views

How to redirect stderr to a file [duplicate]

While using nohup to put a command to run in background some of content appear in terminal. cp: error reading ‘/mnt/tt/file.txt’: Input/output error cp: failed to extend ‘/mnt/tt/file.txt’: Input/...
1
vote
1answer
4k views

How can I capture text from a specific terminal and redirect it to a log file while simultaneously working? [duplicate]

I viewed this question to redirect text to file while displaying the output. My question is how can I redirect it while working AND without constant | tee command. My plan is to use this question to ...
30
votes
4answers
27k 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 ...
18
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?
138
votes
2answers
157k views

What does outputting to /dev/null accomplish in bash scripts? [duplicate]

Oftentimes I run into small bash scripts that use this sort of syntax in if statements: some command > /dev/null 2>&1 What is the purpose of outputting to /dev/null like that, and what does the 2>...
14
votes
1answer
52k views

Redirect requests to my external IP/port to a different external IP/port?

Is it possible to redirect connections to a specific IP/port to an external IP/port? Example: Server A has the external IP xxx.xxx.xxx.xxx Server B has the external IP yyy.yyy.yyy.yyy User sends a ...
11
votes
2answers
46k views

How to redirect output to screen as well as a file?

My aim is to log all output from a script into a directory that the script is going to create. For example, I have: ~/.abc.sh: #! /bin/bash rails new myapp When I run... cd ~/code . ~/.abc.sh ......
26
votes
4answers
4k views

Why does 'ls > ls.out' cause 'ls.out' to be included in list of names?

Why does $ ls > ls.out cause 'ls.out' to be included in list of names of files in current directory? Why was this chosen to be? Why not otherwise?
8
votes
2answers
30k views

Redirecting output to a variable?

I'm interesting in directing the output from two commands to a variable. I don't want the output to be displayed on the screen, but instead assigned to a variable within my script so that I can use ...
4
votes
2answers
274 views

When should I use < or <() or << and > or >()?

I know that <, <(), << all are used to give input and >, >() which are used to redirect output. But I don't know what is clear difference between them and when to use them. Please ...
32
votes
6answers
4k views

In what order does the shell execute commands and stream redirection?

I was trying to redirect both stdout and stderr to a file today, and I came across this: <command> > file.txt 2>&1 This apparently redirects stderr to stdout first, and then the ...
6
votes
1answer
4k views

how to get output of a script/program into a file?

I am compiling a program using make and want the output of make to be written to a file. I have tried using > operator like make > build_log.txt and using tee command like make | tee build_log....
9
votes
4answers
1k views

How do `>` and `>>` work?

I tried to rev a file and then pipe it to cat > same_file but it was turning into a blank file. While I tried rev file.txt | cat > file2.txt && mv file.txt file2.txt; it worked. ...
5
votes
3answers
4k views

How to make zenity “transient parent” warning disappear permanently [duplicate]

Zenity annoys me by always displaying the warning in terminal: Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged. Apparently I'm not the only one: linuxquestions.org - ...
3
votes
1answer
200 views

Bash file redirection bug?

From what I understand about program IO, there are stdin, stdout, and stderr data streams (and a return code). stdout and stderr are the two data output streams. So if I use bash redirection to close ...
2
votes
3answers
635 views

How do I suppress GtkDialog warnings in zenity and yad using Bash redirection in a script?

I'm trying to suppress GtkDialog warnings in zenity and yad: $ zenity --error --text hello Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged. Error redirection and ...
2
votes
1answer
397 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 ...
11
votes
5answers
980 views

Shorten or merge multiple lines of `&> /dev/null &`

Every time starting the machine, I run the following program: $ cat start.sh #! /bin/bash google-chrome &> /dev/null & lantern &> /dev/null & xdg-open . &> /dev/null &...
7
votes
4answers
13k views

Make URL point to local folder

I have a URL to be mapped, on my Ubuntu 16.04 machine, to a local folder. E.g. I need https://domainxxx.xxx to point to /home/user/folder. My specific need is to include domainxxx.xxx/file.js not as ...
6
votes
1answer
11k views

Redirect speaker output to microphone

Can I redirect the output of the speakers to my microphone? I don't want to turn on the speakers. What I want to achieve is, say I'm doing a video chat and want the other person to listen to the ...
10
votes
3answers
812 views

How to understand the ordering of output redirection? [duplicate]

So I am trying to learn how to pass standard out and standard err to various areas. Let's say I have a folder with here.txt alone. So if I do ls here.txt not-here.txt 1>out 2>&1 Since ...
0
votes
4answers
1k views

why pipes are used instead of input redirection

I'm new to linux systems and I can't really understand why wee need two operators that can redirect output: pipe as | and ouput redirection operator >? Can't we just always use the second? Most of ...
4
votes
2answers
350 views

Redirection executed before a command

In many Linux books is written that 'redirection is executed before a command'. Let's consider: $ cat bar hello $ ecno "foo" > bar bash: ecno: command not found $cat bar If bar would not exist, ...
2
votes
1answer
2k views

Output not redirecting to file

I'm experiencing weirdness (or rather showing Linux ignorance). I want to learn the probability distribution of ping requests, so I thought I'd ping some random site for a while, grep the output to ...
1
vote
1answer
645 views

How can I write to stderr so that stderred colours it red?

For background, I previously asked this question. I am using stderred to turn stderr text in red when diplayed on a terminal. This works nicely on most occasions, more specifically for what appear ...
1
vote
1answer
575 views

How to redirect in local domain web site www.mydomain.com/website to www.mydomain.com

I have install simple web service (MediaWiki) in my local server. In my DSN server I have set IP address to this webserver, so now when I call in browser (this works only in my domain IP range) www....