Posted on November 16, 2014, 11:09 pm
Bad command
echo $(date "+%Y%m%d")$(($(date "+%H")-1))
Why ? : the output format is only one digit from (0-9) for midnight (00h) you will have (00-1) -> WTF !
Good command
"OK but not the top one :/" and this one cans only decrease
echo $(date "+%Y%m%d")$(date +%H -d "1 hour ago")
Good command
"Yes, this one is perfect :)"
echo $(date "+%Y%m%d%H" -d "1 hour ago")
Get time by increasing or decreasing an hour in Linux command |
/!\with the same command you can decrease by day or year
Ex:
echo $(date "+%Y%m%d%H" -d "1 day ago") echo $(date "+%Y%m%d%H" -d "1 year ago")
echo $(date "+%Y%m%d%H" -d "1 day ago")
echo $(date "+%Y%m%d%H" -d "1 year ago")
find . -exec ls -dl \{\} \; | awk '{print $3, $4, $9}'
ps aux | grep non_du_processus_ou_non_du_script
du -h /dir/size
du -ch | grep total