
Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [tlug] deleting a local list of filenames from remote server
On Tuesday December 2 2008 19:12, Clemens Schwaighofer wrote:
>I do this in one of my scripts
>
>scp $delete_list target_user@example.com:~;
>ssh -f target_user@example.com "cat ~/$delete_list_file | xargs rm -fv"
Are $delete_list and $delete_list_file the same? From your usage, i'm
going to assume they are, but if not, then please disregard everything
else i say below.
While what you have should work (though i'm not sure what the "-f" is
being used for), rewriting it a bit would have 2 advantages. Namely,
that only one ssh connection would be required (your commands use 2)
thus giving you a performance improvement, and it would not leave a
copy of $delete_list on the server. Here's how i'd rewrite it:
cat $delete_list | ssh -f target_user@example.com 'xargs rm -fv'
If you're one of those people who are bothered by superfluous uses
of "cat", then it can be made (slightly) shorter, but in my humble
opinion, less clear to read:
ssh -f target_user@example.com 'xargs rm -fv' < $delete_list
Note that in the case that $delete_list is not a static file, but is
being generated by the standard output of $some_program, you could use
a variation of my first syntax to never use a temporary file at all:
$some_program | ssh -f target_user@example.com 'xargs rm -fv'
------------------------------------------------------------------------
Dan Ramaley Dial Center 118, Drake University
Network Programmer/Analyst 2407 Carpenter Ave
+1 515 271-4540 Des Moines IA 50311 USA
Home |
Main Index |
Thread Index