Quantcast
Channel: a shell script to list files with date-1 - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 2

Answer by Tomasz for a shell script to list files with date-1

$
0
0

Use the date command:

date --date=yesterday +%Y%m%d
20181103

You can substitute it in a string with:

$ echo pre__"$(date --date=yesterday +%Y%m%d)"__post
pre__20181103__post

If you understand this, you can now use ls and globbing, adjusting the searched pattern as needed. Eg.:

$ ls *pre__"$(date --date=yesterday +%Y%m%d)"__post*
pre__20181103__post

This has listed the file pre__20181103__post present in the current directory.


Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>