pass stdout as file name for command line util?

Solution 1: Using process substitution The most convenient way of doing this is by using process substitution. In bash the syntax looks as follows: foo -o >(other_command) (Note that this is a bashism. There’s similar solutions for other shells, but bottom line is that it’s not portable.) Solution 2: Using named pipes explicitly You can … Read more

Pass a password to ssh in pure bash

You can not specify the password from the command line but you can do either using ssh keys or using sshpass as suggested by John C. or using a expect script. To use sshpass, you need to install it first. Then sshpass -f <(printf ‘%s\n’ your_password) ssh user@hostname instead of using sshpass -p your_password. As … Read more

How to extract tar archive from stdin?

Use – as the input file: cat largefile.tgz.aa largefile.tgz.ab | tar zxf – Make sure you cat them in the same order they were split. If you’re using zsh you can use the multios feature and avoid invoking cat: < largefile.tgz.aa < largefile.tgz.ab tar zxf – Or if they are in alphabetical order: <largefile.tgz.* | … Read more

Pipe input into a script

Commands inherit their standard input from the process that starts them. In your case, your script provides its standard input for each command that it runs. A simple example script: #!/bin/bash cat > foo.txt Piping data into your shell script causes cat to read that data, since cat inherits its standard input from your script. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)