1
Is there a compact way to list files, with the host name prepended? My efforts to combine ls
, xargs
, paste
and process substitution have failed me.
This is the best I came up with:
ls * | paste <(echo $HOST)
Ultimately I want to list a bunch of files across multiple hosts by invoking a series of ssh commands so that I can do something like this:
ssh host1 "ls_with_hostname_prefix /var/log/*"
ssh host2 "ls_with_hostname_prefix /var/log/*"
ssh host3 "ls_with_hostname_prefix /var/log/*"
Man that's so obvious and I completely missed it, trying to be clever with the much less useful
paste
command. – Sridhar Sarnobat – 2016-12-21T22:32:10.700Just a note to anyone else reading: Double quotes so hostname gets resolved. (I'd edit it myself but stack overflow says my edits are too short) – Sridhar Sarnobat – 2016-12-21T23:13:32.237