Hot answers tagged

57 votes

Downloading Youtube videos in a text file...?

Rather than piping it in, you could use functionality provided by youtube-dl - it has a parameter that allows you to point at a text file containing a list of URLs - one per line. -a, --batch-file ...
Attie's user avatar
  • 19.9k
40 votes
Accepted

Is pipe ( | ) a command?

In Bash a pipe (| along with |&) is not a command, rather it is a control operator. From this reference: A pipeline is a sequence of one or more commands separated by one of the control operators ...
squillman's user avatar
  • 7,716
39 votes
Accepted

What does the last "-" (hyphen) mean in options of `bash`?

Bash behaves in somewhat non-standard way when it comes to -. POSIX says: Guideline 10: The first -- argument that is not an option-argument should be accepted as a delimiter indicating the end ...
Kamil Maciorowski's user avatar
34 votes

In windows, can I redirect stdout to a (named) pipe in command line?

I am surprised that this has't been answered correctly already. There is indeed a UNC path assigned to named pipes by the system, accessible on any machine in the network, which can be used like a ...
IS4's user avatar
  • 1,450
29 votes

With regards to piping commands, what are the greater than (>) and less than (<) symbols called?

> is used to redirect output. $ echo "hello" > file.txt < is used to redirect input. $ cat < file.txt Output: hello >> is used to append output to the end of the file. $ ...
Mathieu Gemard's user avatar
26 votes

What does "2>&1" do when posted BEFORE 1>x?

A further example might be helpful: let's redirect fd1 to a file, redirect fd2 to fd1, then redirect fd1 to a different file: $ ( echo "this is stdout"; echo "this is stderr" >&...
glenn jackman's user avatar
20 votes
Accepted

ffmpeg pipe images extracted from video

yes there is! add the argument -f image2pipe, and specify the output filename as a single hypen (-, in this context it means stdout), and specify the input filename also as a single hypen (-i -, in ...
hanshenrik's user avatar
  • 1,665
16 votes

Preserve colors while piping to tee

I'll expand the script solution given in the comment of the accepted answer. Using script may be useful in case you can't or don't want to install the expect package that contains the unbuffer command....
Juuso Ohtonen's user avatar
16 votes

Using -replace on pipes in powershell

To use the Powershell -replace operator (which works with regular expressions) do this: cat file.txt | foreach {$_ -replace "\W", ""} # -replace operator uses regex note that the -...
politus's user avatar
  • 269
16 votes
Accepted

Get response body and show HTTP code by curl

It looks like the content of the response is a single line. You could use two read calls to read two lines: curl -s -w "\n%{http_code}" 'https://swapi.dev/api/people/1?format=json' | { ...
janos's user avatar
  • 3,357
16 votes

Circumventing "Remote Host Identification Has Changed" warning

If you want to pass arguments to a something pre-defined in Bash, you could use a function instead of an alias to the same effect: ssh-keyrm() { ssh-keygen -f "$HOME/.ssh/known_hosts" -R "$1"; } ...
Smartster's user avatar
  • 161
15 votes

Why does Powershell silently convert a string array with one item to a string

Note the difference between these two results: PS C:\> ConvertTo-Json -InputObject @(1) [ 1 ] PS C:\> @(1)|ConvertTo-Json 1 PS C:\> The point is that the 'unboxing' is being done by the ...
Larry Young's user avatar
15 votes
Accepted

mpv: how to play a list of URLs piped from stdin

The --playlist option allows you to specify a playlist from stdin if you use - as path, Example: ls | mpv --playlist=-
dec05eba's user avatar
  • 166
13 votes
Accepted

Xargs pass input to command that contains a pipe

Here you are with xargs: find . -type d|xargs -I % sh -c 'find % -type f -maxdepth 1 | head -1' But remember: internal loop is much faster! time find $PWD -type d | while read dir;do find $dir -...
Ipor Sircer's user avatar
  • 4,093
13 votes

Circumventing "Remote Host Identification Has Changed" warning

you cannot provide an argument to alias Bash aliases work as simple expansions (the alias name just gets replaced with the alias value), so they cannot reference individual arguments using $n. ...
u1686_grawity's user avatar
12 votes

Setting pipefail for a single piped command

Not sure why it wasn't mentioned above, but it is possible to explicitly unset pipefail, using set +o pipefail. set -o pipefail command1 | command2 | command3 set +o pipefail If you are executing a ...
robbat2's user avatar
  • 1,254
12 votes
Accepted

Pipe ffmpeg output to other process

You have to provide the format with -f, such as: ffmpeg … -f matroska - | process For a list for available formats see ffmpeg -formats. Note that some formats (typically MOV), require the output ...
llogan's user avatar
  • 59.1k
12 votes

What does "2>&1" do when posted BEFORE 1>x?

From man bash: "Note that the order of redirections is significant. For example, the command ls > dirlist 2>&1 directs both standard output and standard error to the file dirlist, ...
10 votes
Accepted

Why is Bash reporting “command not found” in some cases in the Terminal but not in others?

There’s a hint to the problem in the error message; there’s an extra space showing: bash: wc: … Rather than: bash: wc: … I assume from your question you’re using a Mac. I’m going to guess that ...
Kevin Reid's user avatar
  • 3,392
10 votes
Accepted

filter outputs using select-string pipes

By default Out-String produce single string object, which contain all the output, so the following filter will select or discard all output as whole. You need to use -Stream parameter of Out-String ...
user364455's user avatar
  • 2,999
10 votes
Accepted

Writing to a file from a udev RUN command

Operators like |, >> etc. mean something while inside a shell, but when sole /bin/echo 1 | … is run, there is no shell and | is just another argument to echo itself. To use these operators you ...
Kamil Maciorowski's user avatar
9 votes

Pipe gunzip and mysql to gunzip a dump and import it

All other answers are recommending writing the password in the command. This is a very bad practice and poses security risks. Please DON'T DO that. You can leave the password empty in the command, ...
Elin Y.'s user avatar
  • 191
9 votes

Bash: create anonymous fifo

While @DavidAnderson's answer covers all the bases and offers some nice safeguards, the most important thing it reveals is that getting your hands on an anonymous pipe is as easy as <(:), as long ...
clacke's user avatar
  • 308
9 votes

How to suppress cUrl's progress meter when redirecting the output?

According to man curl: -s, --silent : Silent or quiet mode. Don't show progress meter or error messages. Makes Curl mute. Example usage: curl -s 'http://www.google.com' or if you want to capture ...
Venkatt Guhesan's user avatar
9 votes

How to concatenate two lines with `sed`?

sed is a text tool. By default it outputs one line of output per one line of input. While it's easy to inject newlines into the output (making it more lines), it's not that easy to get rid of newlines ...
Kamil Maciorowski's user avatar
9 votes
Accepted

How/why does ssh output to tty when both stdout and stderr are redirected?

How? How is ssh doing this? It opens /dev/tty. The relevant line from strace ssh … is: openat(AT_FDCWD, "/dev/tty", O_RDWR) = 4 The file descriptor 4 is then used with write(2) and ...
Kamil Maciorowski's user avatar
8 votes
Accepted

GNU "parallel --pipe" doesn't process stdin by lines

You are SO close. -L sets the record size (in lines) but not how many records should be sent. This is controlled by -N. Default --recend is \n so that is not needed. Default -L is 1, so that is not ...
Ole Tange's user avatar
  • 4,789
8 votes

How can I redirect output from stdout into vim?

You're missing the - filename argument that instructs Vim to fill the buffer from stdin; cp. :help -- echo $PATH | vim - Alternatively, you can use your shell's process substitution to create a ...
Ingo Karkat's user avatar
8 votes

Circumventing "Remote Host Identification Has Changed" warning

I have a similar problem with different devices using the same IP, but took a slightly different approach to solve it: prevent the host keys from going in to known_hosts in the first place. alias ...
josh3736's user avatar
  • 4,053
8 votes
Accepted

Circumventing "Remote Host Identification Has Changed" warning

Another solution to prevent the host key from being saved in the first place Please note that this will disable part of what makes ssh secure, the verification that the host you are connecting to is ...
Pelle's user avatar
  • 276

Only top scored, non community-wiki answers of a minimum length are eligible