LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-17-2019, 05:57 PM   #1
bloodclot
LQ Newbie
 
Registered: Apr 2012
Posts: 13

Rep: Reputation: Disabled
Script Help


Hello,

I am downloading a bunch of files via sftp, the files look like -

AKE_US_INVENTORY_20190717041517.csv
AKE_US_INVENTORY_20190716041518.csv
AKE_US_INVENTORY_ADJ_20190717041517.csv
AKE_US_INVENTORY_ADJ_20190716041518.csv
AKE_US_PREVDAY_SHIP_20190717041518.csv
AKE_US_REFUSAL_RECEIPTS_20190717041519.csv

I want to remove the files that are not from current day...

So _20190717* is the current date...

Thanks in advance!
 
Old 07-17-2019, 06:08 PM   #2
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,735

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by bloodclot View Post
Hello,

I am downloading a bunch of files via sftp, the files look like -

AKE_US_INVENTORY_20190717041517.csv
AKE_US_INVENTORY_20190716041518.csv
AKE_US_INVENTORY_ADJ_20190717041517.csv
AKE_US_INVENTORY_ADJ_20190716041518.csv
AKE_US_PREVDAY_SHIP_20190717041518.csv
AKE_US_REFUSAL_RECEIPTS_20190717041519.csv

I want to remove the files that are not from current day...

So _20190717* is the current date...

Thanks in advance!
You have the answer already: _20190717* or _20190717*csv in your sftp command.
 
Old 07-17-2019, 06:19 PM   #3
bloodclot
LQ Newbie
 
Registered: Apr 2012
Posts: 13

Original Poster
Rep: Reputation: Disabled
Well, the date changes.. I will download the files nightly..

I am using sshpass and scp and mget * to download all the files..

Then planned to use another script to parse the files and rm the non current date..
 
Old 07-17-2019, 06:28 PM   #4
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,735

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by bloodclot View Post
Well, the date changes.. I will download the files nightly..

I am using sshpass and scp and mget * to download all the files..

Then planned to use another script to parse the files and rm the non current date..
just don't pull the non-current date each day
Code:
mget AKE_US_INVENTORY_20190717*
The transfer will be quicker, and the logic is simpler...

You can script formatting the current date to match the format in the filename.
See man date
 
Old 07-18-2019, 02:52 AM   #5
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,008

Rep: Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193
Just to confirm, when asking for script help, it is generally expected that we will see your script so we may assist
 
2 members found this post helpful.
Old 07-19-2019, 11:38 PM   #6
FlinchX
Member
 
Registered: Nov 2017
Distribution: Slackware Linux
Posts: 666

Rep: Reputation: Disabled
Since you are going to do some scripting, why not filter files before downloading?
 
Old 07-20-2019, 08:45 AM   #7
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,930

Rep: Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321
additionally you used find in your other thread. This can be solved easily using find, see man page (about time related options)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
help: using cron + my bash script --> don't want mail from script beeblequix Linux - General 7 11-23-2007 09:25 PM
Need help with a simple script shell script WindowBreaker Linux - Software 2 12-15-2005 12:45 PM
logrotate shell script help with existing script sridhar11 Debian 7 11-04-2005 04:11 AM
Help, help help help help drknownothing Linux - Networking 2 10-24-2004 03:05 AM
help, help, help, help, help....cmi8738 will not work... AMArt79196 Red Hat 2 07-05-2004 06:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration