0

I have the following code, thanks to @Janis for the help with the process substitution.

Also, apologies for creating a new question, I haven't received any recent replies on the thread of my previous one, I can't add a bounty to that one, and I'm really stuck. I hope it's ok

The dates on the html pulled with curl request are this format: 2015-04-06 09:40:37

Two dates are being extracted with awk and assigned to the variables new and old respectively, but the strings are being split on white space within the date strings. I tried changing OFS to ',', but it was still splitting incorrectly.

IFS="," 
read dateStrNew dateStrOld < <(curl -k -q "$curl_call" | html2text | gawk '/Newest Sequence/ { new=$3" "$4 }/Oldest Sequence/ \
 {old=$3" "$4}END {OFS=","; print new,old }')  //new = date, old = date

sample output with IFS ',' (newest = dateStrNew ; oldest = dateStrOld)

newest ,

oldest 

newest 1428350400

oldest 

newest ,

oldest 

newest 2015-04-07 06

oldest 29:29,2015-04-06 09:40:37

newest ,

oldest 

newest 2015-04-07 06

oldest 29:29,2015-04-06 09:40:37

curl request is https://username:password@ip/report

Two dates are contained within the html report, in this format: 2015-04-06 09:41:14

So I am searching for "Newest Date" and "Oldest Date" within the html file, pulling the fields from that line containing the date, assigning the two fields to a variable. There are two dates, so two awk variables, newest and oldest

  • Could you include example output from curl -k -q "$curl_call" | html2text | gawk '/Newest Sequence/ { new=$3" "$4 }/Oldest Sequence/ \ {old=$3" "$4}END {OFS=","; print new,old }'? – Stephen Kitt Apr 7 '15 at 4:38
  • It's hard to do clearly in comments, but 'newest', 'oldest' are debugging variables which should contain the string output, and then 'date' is once I've run the date command first: newest , oldest date: invalid date' ,' date: invalid date +%s – jewfro Apr 7 '15 at 4:56
  • second: newest 2015-04-07 06 oldest 29:29,2015-04-06 09:40:37 date: extra operand 40' – jewfro Apr 7 '15 at 4:57
  • third: newest , oldest date: invalid date ',' – jewfro Apr 7 '15 at 4:58
  • Does that output make sense? Why are there error messages instead of dates? And please edit your question with the extra information (instead of adding comments). Thanks! – Stephen Kitt Apr 7 '15 at 5:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.