Hacker News new | ask | show | jobs
by Plugawy 4135 days ago
So it's basically:

    tail -f <(ssh -t host 'tail -f /var/log/sth') <(ssh -t host2 'tail -f /var/log/sth')
+ I need to install nodejs?
2 comments

I have no problem with people writing cool little tools like this in whatever language, but there seems to be a chronic lack of understanding of what existing tools can do.
Henry Spencer 11/15/87

    Those who do not understand Unix are condemned to reinvent it, poorly.
The interface to this tool is far nicer to work with. Can you replicate that interface with your command?

Serious question - I actually would like to see how you'd do it.

You can have something like this in your .bashrc:

    multitail() {
        com="tail -f "

        for arg; do
            IFS=':' read -a array <<< "$arg"
            host="${array[0]}"
            file="${array[1]}"

            com="$com <(ssh -t $host 'tail -f $file')"
        done

        eval ${com}
    }
This will take the host:file syntax of remtail and turn it into Plugawy's example. I haven't tested it, but if you echo "$com" it'll spit out Plugawy's code.
nice solution! bash looping and arrays always seemed overly complex and confusing to me, but this is not nearly as complicated as I expected.