IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to remove remote file older than X days in SFTP


IBM Mainframe Forums -> All Other Mainframe Topics
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ssuthagar

New User


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

PostPosted: Thu Jun 04, 2020 6:26 am
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 Member


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

PostPosted: Thu Jun 04, 2020 10:56 am
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: 2455
Location: Hampshire, UK

PostPosted: Thu Jun 04, 2020 1:16 pm
Reply with quote

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

Superior Member


Joined: 14 Mar 2007
Posts: 10801
Location: italy

PostPosted: Thu Jun 04, 2020 2:15 pm
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

Superior Member


Joined: 14 Mar 2007
Posts: 10801
Location: italy

PostPosted: Thu Jun 04, 2020 2:48 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> All Other Mainframe Topics

 


Similar Topics
Topic Forum Replies
No new posts Convert PS to TXT file using jcl JCL & VSAM 7
This topic is locked: you cannot edit posts or make replies. Sort to include records of file 2 int... Java & MQSeries 1
No new posts How to modify file content using REXX CLIST & REXX 3
No new posts VB file copy COBOL program gives erro... COBOL Programming 3
No new posts SORT for dynamic trailer record + CSV... DFSORT/ICETOOL 14
Search our Forums:

Back to Top