如何在Linux Shell脚本或python中找出最后一个星期六的日期? [英] How to find out the date of the last Saturday in Linux shell script or python?
本文介绍了如何在Linux Shell脚本或python中找出最后一个星期六的日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有python脚本,我需要每天运行该脚本以进行备份. 现在,我需要找到上一个星期六的日期,因为我需要在脚本中获取上一个星期六的备份.假设
I have python script which i need to run daily for backups. Now i need to find the date of last saturday because i need that in my script to get the backups i did on last saturdy. Suppose
我在星期六制作了这个文件
on saturday i made this file
weekly_user1_Jul-13-2013.sql
我想在每天运行的脚本中获取该名称.因此,对于在周六运行的脚本,我需要获取今天的日期,将其保存在周日,那么我需要获取最后的周六日期.
I ned to get that name in script which i run daily. so for script running on saturday i need to get todays date , buif its on sunday then i need to get last saturday date.
我该怎么做
推荐答案
$ date +"%b-%d-%Y" -d "last saturday"
Jul-13-2013
这篇关于如何在Linux Shell脚本或python中找出最后一个星期六的日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文