Show the date of easter
$ ncal -e ncal -e shows the date of Easter this year. ncal -e YYYY shows the date of Easter in a given year. ncal -o works the same way, but for Orthodox dates. View this command to comment, vote or...
View ArticleGet yesterday's date or a previous time
$ date -d '1 day ago'; date -d '11 hour ago'; date -d '2 hour ago - 3 minute'; date -d '16 hour' With this command you can get a previous or future date or time. Where can you use this? How about...
View ArticleShow changed files, ignoring permission, date and whitespace changes
$ git diff --numstat -w --no-abbrev | perl -a -ne '$F[0] != 0 && $F[1] !=0 && print $F[2] . "\n";' Only shows files with actual changes to text (excluding whitespace). Useful if you've...
View Articlefind files in a date range
$ touch -t 201001010000 begin; touch -t 201012312359.59 end; find . -newer begin -a ! -newer end Example above will recursively find files in current directory created/modified in 2010. View this...
View Articlefind files in a date range
$ find . -type f -newermt "2010-01-01" ! -newermt "2010-06-01" Find files in a specific date range - in this case, the first half of last year. -newermt = modification time of the file is more recent...
View ArticleGet the date for the last Saturday of a given month
$ cal 04 2012 | awk 'NF <= 7 { print $7 }' | grep -v "^$" | tail -1 This is a little trickier than finding the last Sunday, because you know the last Sunday is in the first position of the last...
View ArticleShow all files sorted by date
$ FINDDATE() { LOCATION="${1:-.}"; find ${LOCATION} -type f -print0 | xargs -0 stat -c "%y %n" | sort | sed 's/.\([0-9]\)\{9,\} +0[1-2]00/\t/' | sed 's/ /\t/g' } a quick function for searching changed...
View ArticleDelete files sorted by dates. Delete all other files except latest N files.
$ ls -lt | grep ^- | awk 'NR>=N {print $9}' | xargs rm -rf -i View this command to comment, vote or add to favourites View all commands by clongbupt Diff your entire server config at ScriptRock.com
View ArticlePrepend section dates to individual entries in a summary log file
$ gawk 'match($0, /^\s*([0-9]{2}\/[0-9]{2}\/[0-9]{4})\s*/, m) {prev_date=m[1]} /SEARCHSTRING/ {print prev_date, ",", $1 $2, ",", $3, "," $5}' inputfile.txt Searches for dates on lines by themselves....
View ArticleList all files in a folder in a git repository by last commit date
$ git ls-tree --name-only HEAD foldername/ | while read filename; do echo "$(git log -1 --format="%ci " -- $filename) $filename"; done | sort -r This lists all the files in a folder, then finds the...
View Article