Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
How to remove remote file older than X days in SFTP

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics
View previous topic :: :: View next topic  
Author Message
ssuthagar

New User


Joined: 03 Oct 2017
Posts: 3
Location: United States

PostPosted: Thu Jun 04, 2020 6:26 am    Post subject: How to remove remote file older than X days in SFTP
Reply with quote

Hi Seniors.

I need to issue the sftp command to remove the multiple files in Unix server which are older than 30 days from Mainframes.

I am using below command

cd /file path/

rm *csv<30D

but this commands throws an error " there is no such file or directory.

When I tried issuing below command

rm *.csv <30D

it removes all the files irrespective of older than 30 days.

Can someone please help me how to achieve this.

Thanks in advance,
Suthagar
Back to top
View user's profile Send private message

Joerg.Findeisen

Active User


Joined: 15 Aug 2015
Posts: 277
Location: Bamberg, Germany

PostPosted: Thu Jun 04, 2020 10:56 am    Post subject:
Reply with quote

As sftp is not a shell or remote file manager, I don't think it's feasible this way.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2365
Location: Hampshire, UK

PostPosted: Thu Jun 04, 2020 1:16 pm    Post subject: Reply to: How to remove remote file older than X days in SFTP
Reply with quote

Surely you want >30D?
Back to top
View user's profile Send private message
enrico-sorichetti

Senior Member


Joined: 14 Mar 2007
Posts: 10691
Location: italy

PostPosted: Thu Jun 04, 2020 2:15 pm    Post subject: Reply to: How to remove remote file older than X days in SFTP
Reply with quote

surely You might want to read the manual
or use the man command to look at the help pages


the < and > in the whatever shell You are using are the redirection operators for stdin and stdout

for the rm command the < operator does NOTHING
rm does not read from stdin

the > operator will write the stdout of whatever command You issued to the file specified after the >

TESTED and VERIFIED that ...
using sftp the < and > do nothing
in bash and zsh the behavior is as described

TESTED and VERIFIED before posting ( as I always do icon_cool.gif )
Back to top
View user's profile Send private message
enrico-sorichetti

Senior Member


Joined: 14 Mar 2007
Posts: 10691
Location: italy

PostPosted: Thu Jun 04, 2020 2:48 pm    Post subject: Reply to: How to remove remote file older than X days in SFTP
Reply with quote

anywahy we cannot provide any proper soulution because we do not know about the TS setup
( specifically authorization ad ssh capabilities )

the usual way would be to use the find command with the proper selection criteria

something like ...

ssh the target system with the proper credentials

cd to the working directory

find . -type f -name "*.csv" '... the date and time selection arguments...' -exec rm {} \;

I expect the TS be able to look at the man page for the find command and determine the proper date time selection format
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Identify the count from two diffrent ... UmashankarSubramani DFSORT/ICETOOL 8 Sat Jul 11, 2020 4:35 am
No new posts CICS file processing using applicatio... Satish_gsv CICS 3 Sat Jul 11, 2020 4:18 am
No new posts Problem getting record length of a re... amitc23 COBOL Programming 2 Thu Jul 02, 2020 10:52 pm
No new posts Want to check if trailer count is 0 a... rohanthengal JCL & VSAM 10 Fri Jun 26, 2020 10:47 am
No new posts File transfer to remote system using ... kalyan.lc5 TSO/ISPF 2 Wed Jun 24, 2020 1:24 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us