dealing with dates in a text file
hi guys im trying to write a bash script that grabs expired domain names it leaves me with the following outpiut in a text file
Quote:
Im hoping to try to normalise all the dates to the format displayed in the first 2 lines and remove the times so the file looks unfirom can any one give me a heads up ? Thanks for looking |
Just 'awk -F'Date:' '{print $NF}';' the time stamp I'd say because 'date' accepts input through "--date" so 'env TZ=UTC date --date="Mar 26 23:59:59 2012" +'%s';' works as does 'env TZ=UTC date --date="27-Jul-2012" +'%s' (for '%s' substitute your own format of course).
|
Hi.
If you have GNU sed then Code:
$ sed 's/\(.*Date:\)\(.*\)/echo "\1" `date -d "\2" +%d-%b-%Y`/e' infile.txt |
Quote:
Quote:
Quote:
|
Quote:
|
If you don't mind a non-standard utility you could use my dateutils
Specify all possible input dates with -i and the desired output format with -f. The -S stands for sed mode, to change the dates within the input line: Code:
dconv -S -i '%d-%b-%Y %T' -i '%d-%b-%Y' -i '%b %d %T %Y' -f '%b-%d-%Y' <<EOF |
All times are GMT -5. The time now is 07:27 AM. |