regex - Bash, Awk dynamically matching shell variable (Darwin BSD) -


i have series of .csv files similar this:

facility, room, sn, alert_start, alert_end foo, bar, 28g63, 5/16/16 12:24, 5/30/16 12:24 foo, bar, 58dfy, 5/11/16 12:25, 5/30/16 12:24 foo, bar, dd8f6, 5/27/16 12:25, 5/30/16 12:24 foo, bar, 397d2, 5/24/16 12:24, 5/30/16 12:24 

each file holding different matched pair of "room" , "alert_end" values.

i trying arrange .csv report in week's worth of "room" , "alert_end" pairings contained in 1 file, "sn" being other data showing. needs arranged this:

room.csv 5/26/16, 5/27/16, 5/28/16, 5/29/16, 5/30/16, 5/31/16, 6/1/16 28g63, 28g63, 28g63, 28g63, 28g63, 28g63, 28g63 58dfy, 58dfy, 58dfy, 58dfy, 58dfy, 58dfy, 58dfy      , dd8f6,     ,      ,       , dd8f6, 397d2, 397d2, 397d2, 397d2, 397d2, 397d2, 397d2 i58d7,      ,      ,      , i58d7, i58d7, i58d7 

here code block attempting formatting:

function organizetext {         in {0..6};                 day=$(date -v-${i}d +%y-%m-%d)                 day2=$(date -v-${i}d +%m/%d/%yy)                 file=/tmp/$day"_$facility".csv                 echo $day > $file                 awk -f "," -v cow=$day2 '$5 ~ cow { print $3 }' "/tmp/$facility.csv" >> $file         done          touch "/tmp/master_$facility.csv"          in {0..6};                 day=$(date -v-${i}d +%y-%m-%d)                 paste -d, "/tmp/master_$facility.csv" /tmp/$day"_$facility".csv > "/tmp/master_$facility.csv"         done } 

whenever try run this, of '/tmp/$day"_$facility".csv' files contain same full list of sn values associated facility, regardless of whether match date or not.

any guidance appreciated.

the problem turned out not awk, bash, or regex code.

the problem way in microsoft excel automatically formats , displays dates.

i trying write regex match seeing in .csv file opened excel formatted dates this: 5/23/16

but when opened .csv file in text editor, date formatted string this: 2016-05-23

i fixed regex match formatting shown via text editor, , code worked.


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

python 3.x - PyQt5 - Signal : pyqtSignal no method connect -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)