Command "FIND" does not work with SFTP connection

P

projjwal

Guest
Hi,

Iam bit new to shell scripting.

As one of our requirement was to connect to remote Linux server through SFTP connection and delete some files which are older than 7 days.

I used the below piece of code for that,

SFTP_CONNECTION=`sftp user_id@host ...
cd DESIRED_DIR;
find /path/to/files* -mtime +7 -exec rm -rf {} \;
bye
END`

But unfortunately, "find" command does not work with "SFTP" connection, and as a result, iam unable to remove files from remote server.

I even can not use "SSH" for security purpose. And the script is fired from "ksh".

So my question is, how can we delete files from remote server through "SFTP".

Or, is there any alternative command of "ls" which does the exactly same thing as,

"find /path/to/files* -mtime +7 -exec rm -rf {} \;"

Thanks
Projjwal
 

Staff online

Members online


Top