Portal | 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: 6
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: 311
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: 2408
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: 10700
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: 10700
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 TWS - ETT File triggering does not wo... me00266 IBM Tools 4 Mon Sep 07, 2020 11:58 pm
No new posts How to process dependent file based o... HithaSri JCL & VSAM 8 Sun Sep 06, 2020 12:42 pm
No new posts EIBRESP =16 & EIBRESP2 = 01 while... Farheen CICS 4 Mon Aug 24, 2020 2:05 pm
No new posts Dynamic file read via JCL abdulrafi JCL & VSAM 4 Fri Aug 14, 2020 11:51 am
No new posts to Insert Rows from File1 to File 2 ... Arun_Tupili DFSORT/ICETOOL 1 Thu Aug 13, 2020 6:22 pm

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