Tag Info

New answers tagged

2

Here's another way to do it. Let's say we have two files, file1: Dave 734.838.9800 Bob 313.123.4567 Carol 248.344.5576 Mary 313.449.1390 Ted 248.496.2204 Alice 616.556.4458 Jimmy 324.555.8867 Harry 422.858.2354 Lou 788.907.6859 and file2: Bob Tuesday Carol Monday Jimmy Wednesday Ted Sunday Alice Wednesday Dave Thursday Harry Monday Mary Saturday Lou ...


2

awk ' BEGIN { print "Name On-Call Phone" split("MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY SUNDAY", days); } NR == FNR { day[$1] = $2; next } { lines[toupper(day[$1])] = $1 OFS toupper(day[$1]) OFS $2 } END { for (i=1; i<=7; i++) { if (lines[days[i]]) print lines[days[i]] ...


1

GNU date accepts a number of relative dates that you can supply with the -d flag. $ date -d '+1year' Sun Apr 17 09:15:14 PDT 2016 See Relative items in date strings for details.


1

If you want to let date create the standard date formatting you could do: $ date -d "$( date -d "Fri Apr 17 20:16:01 IST 2015" "+2016-%m-%d %T" )" But you can also use just one date instance and use the appropriate time format specifiers, as in: date -d "Fri Apr 17 20:16:01 IST 2015" "+%a %b %e %T %Z 2016" Or - since your date format has the year at ...


0

The date syntax is arcane and error-prone, which makes a command-line invocation a pain. I therefore wrote a small script (I named it worldtime), which will print the specified (or current) time from base time zome (your local one) in some other time zones and the converse. Here it is. Adjust it to match your needs, put it in your path, and make it ...


1

This code does the comparison and informs you by printing a message on the console where you typed the command: [[ $(date +%Y%m%d -d $(< file)) == $(date +%Y%m%d) ]] && echo "wake up" You may want to replace the echo by any other command that notifies you, e.g., use the command mail.


2

This is untested for dates surrounding a years end, but should give you enough to work out the rest: fdotw=$(($1 - ($(date -d @$1 +"%u") - 1) * 3600 * 24)) ldotw=$(($fdotw + 6 * 24 * 3600)) date -d @$fdotw +"%F" date -d @$ldotw +"%F" me@mylaptop:/home/me >fdotw=$((1428909297 - ($(date -d @1428909297 +"%u") - 1) * 3600 * 24)) me@mylaptop:/home/me ...


1

This is more a hint than a solution. IIRC you can use the ISO 8601 date format and a string compare. Something like this might work for you: iso_moment=$(date -u +"%Y-%m-%dT%H:%M:%SZ" -d "-5 days") iso_date=$(date -d $awk_date +"%Y-%m-%dT%H:%M:%SZ") if [[ "${iso_date}" > "${iso_moment}" ]] then echo -e "Date:$date Scan No:$awk_scan_count Part ...


-1

TODAY=$(TZ=":US/Eastern" date) echo $TODAY


1

After some research, I ended up with this. I also applied it to my own server: sudo apt-get install ntp sudo dpkg-reconfigure ntp ntpq -p If the last command shows a valid list of servers, you are good to go. The command will run a quite complex set of algorithms which will iterate your clock drift, among other things, and compensate for them. You will ...


0

The GNU version of date that you're used to on Linux supports a lot more date format than the version of date on most other Unix variants. It also has many options that aren't present on other Unix variants. The only standard usage of date is to display the current date according to a format specified with a +… argument (and also a way for the system ...


1

I don't have a bsd box to test on, but it appears that you need to use this form: date -f "some format" "$datum" "+%Y-%m-%d" and you have to specify the format of the incoming datum so it can be parsed.



Top 50 recent answers are included