Tag Info

New answers tagged

0

echo $(($(date +%s)-$(date -d 00:00 +%s)))


8

To avoid race conditions, still assuming GNU date: eval "$(date +'today=%F now=%s')" midnight=$(date -d "$today 0" +%s) echo "$((now - midnight))" With zsh, you can do it internally: zmodload zsh/datetime now=$EPOCHSECONDS strftime -s today %F $now strftime -rs midnight %F $today echo $((now - midnight)) Portably, in timezones where there's no daylight ...


0

Based on bash, get current time in milliseconds since midnight, on a GNU system, it can be done like this: $ now=$(date '+%s') $ midnight=$(date -d 'today 00:00:00' '+%s') $ echo $(( now - midnight )) 53983


1

While writing the question, I see the answer: two steps. $ yes no | unzip myarchive.zip # Unzip only things that don't exist on disk $ unzip -f myarchive.zip # Unzip things that (now) exist on disk and are newer.


2

your drive /dev/sdb1 is mounted in media_2e040 directory now so all the properties of media_2e049 are sdb1 properties. if you change them with touch you have changed sdb1 properties.


1

I had same problem with Cygwin. You need to run dos2unix mkdatedir.sh # or whatever your script is called this will remove any dos carriage returns but better to set option igncr see https://cygwin.com/ml/cygwin-announce/2010-08/msg00015.html


7

Most unices don't track a file's creation date¹. “Creation date” is ill-defined anyway (does copying a file create a new file?). You can use the file's modification time, which is by a reasonable interpretation the date at which the latest version of the data was created. If you make copies of the file, make sure to retain the modification time (e.g. cp -p ...


4

stat --printf='}" "%z_${SN}_${LINENO}"\n' -- * | nl -nln -w1 -s '' | sort -k2,3 | sed 's| ..:[^_]*||;s|-||g;s|^|echo mv "${|' | SN=SHOOTNAME sh -s -- * The above command should do what you need. It is perhaps more general-purposed than you have requested - but please see the bottom of this answer for a more specific example. It works by *globbing all ...


4

Use gsub: a="YYYY-MM-DD" b=a gsub("-", "", b) print(b) will output: YYYYMMDD gsub replaces the first argument with the second in the third, in-place, so we copy the value of a into b first. We replace the - characters with nothing.


0

With relatively recent versions of ksh93: $ printf "%(%Y/%m/%d)T\n" "2014/06/20 +1 day" 2014/06/21 Or: $ printf "%(%Y/%m/%d)T\n" "2014/06/20 next day" 2014/06/21 $ printf "%(%Y/%m/%d)T\n" "2014/06/20 tomorrow" 2014/06/21


0

I don't think account creation is typically logged by default. You can check your backups of /etc/passwd and see which is the youngest backup that doesn't have this account. I use and recommend etckeeper to keep track of changes in /etc, so git annotate /etc/passwd would give me the answer. (Actually git annotate would tell me the last time a user's entry ...


3

if created and not touched since the user creation you can use the .bash_logout file to determine the date. As root run: ls -l /home/<username>/.bash_logout OR, If the user has a home directory, you can check that directories creation date: ls -ld /home/username/ to get only the date you can use awk: ls -ld /home/username/ | awk '{ print ...


0

Most Unix files (directories and files) have three time stamps, defined in /usr/include/sys/stat.h. st_atime: last access time st_ctime: last status change time st_mtime: last modify time Each of these can be changed, and none record the creation date. Even if you try to compare files in a user's directory that were copied from /etc/skel, those files ...



Top 50 recent answers are included