this will remove only files that were successfully copied to the remote host 
and can handle odd characters in the filenames (like with spaces in the 
filenames)

export IFS=$'\n'; for file in $(find . -type f -name "*.txt"); do scp "$file" 
u...@server:/path/to/dir/. && rm -f "$file"; done


On Mon, Oct 05, 2009 at 12:46:27PM -0700, J.T.F. wrote:
> 
> to also delete the file that was sent, I'll assume that you would do
> 
> for file in *.txt; do scp *.txt u...@server:/path/to/directory/.; rm -
> f *.txt; done
> 
> This folder will be actively having more files dropped into it.  I
> don't want to accidentally delete a file that wasn't scp'd.
> 
> Thanks
> 
> 
> 
> On Oct 5, 3:15 pm, hard wyrd <[email protected]> wrote:
> > for file in *.txt; do scp *.txt u...@server:/path/to/directory/.; done
> >
> > On Tue, Oct 6, 2009 at 2:24 AM, JTF <[email protected]> wrote:
> >
> > > This will probably be a no-brainer for many here;
> >
> > > Is it possible to do this in a single line of code?
> >
> > > Find any .txt files
> > > SECURE copy (scp) them to another sytem
> > > delete the file
> >
> > > Thanks
> > > JEFF
> >
> > --
> > Penguin, penguin, and more penguin.
> >
> > Believe that within the brain is a brain, and within it another brain, and
> > so on and so forth.
> > 

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Linux Users Group.
To post a message, send email to [email protected]
To unsubscribe, send email to [email protected]
For more options, visit our group at 
http://groups.google.com/group/linuxusersgroup
-~----------~----~----~----~------~----~------~--~---

Reply via email to