Use process substitution:
nano <(cat /var/log/qmail/current | tai64nlocal)
Also, you don't need to use cat
nano <(tai64nlocal < /var/log/qmail/current)
Question
this is a curiosity. Can i start nano editor from bash, passing a piped command? this is my situation: I've a log file with dates formatted in tai64. For print my file i launch:
$> cat /var/log/qmail/current | tai64nlocal
that print what i want. but i want to view this in nano or another editor in one command. for example:
$> cat /var/log/qmail/current | tai64nlocal > nano
but this doesn't work. Any suggestion? Thanks in advance
La solution 2
Use process substitution:
nano <(cat /var/log/qmail/current | tai64nlocal)
Also, you don't need to use cat
nano <(tai64nlocal < /var/log/qmail/current)
Autres conseils
if you want to nano
to open stdin
use dash-notation (-
):
echo "foo" | nano -
in your case this would translate to
cat /var/log/qmail/current | tai64nlocal | nano -
It didn't work because you are not using pipes. You are using a redirect which works slightly different.
| vs >
By doing
cat /var/log/qmail/current | tai64nlocal > nano
You are piping cat's stdout to tai64nlocal stdin. Then you redirect it's stdout to a filestream, in this case a file named nano in your pwd.
Based on what you wanted, it partially works because the tai command does both printing and echoing to stdout.
Older versions of nano do not support being piped to though. This was introduced in nano 2.2.
You would do
Command | nano -
The single dash tells nano to open stdin as a pager, like more or less would.
davymartu's command "nano < ( cat /var/log/maillog | tai64nlocal )" generates a syntax error because of the space between "<" and "(". If the space is removed, as it is in konsolebox's examples, the command will execute.