Skip to content

Instantly share code, notes, and snippets.

@seqizz
Last active August 29, 2015 14:00
Show Gist options
  • Save seqizz/f600753df20ddb9217f3 to your computer and use it in GitHub Desktop.
Save seqizz/f600753df20ddb9217f3 to your computer and use it in GitHub Desktop.
Parse date from filename (awk)
A reference for parsing date from name. This one parses "2014-04-13_xx-xx-xx" format and prints filenames named before 2 weeks.
ls -1 | sort | awk -F_ -v wk=`date --date="2 weeks ago" +%Y-%m-%d` '{if ($1 < wk) print $1"_"$2 }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment