Hi, Francesco, some amendment:actually, usage of awk for just that translation is not too beneficial, the command can also just be
while read FN SN H M D Y ; do printf "$(date -d "$M $D $Y" +%Y-%m-%d) - $FN $SN\n" ; done
That would be sufficient if your files just contain those lines which all should be modified.
However, if there are also other lines, you would need to distinguish. Uwe Quoting [email protected]:
Hi, Francesco, Regular Expressions match patterns.A solely regexp-based find and replace would be able to replace certain parts of your pattern, but you want bit more. First, I understand you got the month names and need to translate them into the month number. That would be possible with something like the Unix stream editor, sed, using some lengthy expression list but the the (Linux) date command can translate date strings as well. However, you also want to change the order of parts of your lines.I suppose your lines might look like Joe Someone - Apr 1, 2020 then a shell command likeawk -F '-' '{print $2, $1}' | while read M D Y FN SN ; do printf "$(date -d "$M $D $Y" +%Y-%m-%d) - $FN $SN\n"using awk and the date command would do the trick. Example:$ echo "Joe Someone - Apr 1, 2020" | awk -F '-' '{print $2, $1}' | while read M D Y FN SN ; do printf "$(date -d "$M $D $Y" +%Y-%m-%d) - $FN $SN\n" ; done2020-04-01 - Joe Someone Uwe. Quoting Francesco Scaglioni <[email protected]>:HiOn the off chance that the FOSS community are more likely to know about reg excsI have a number of docs that contain on a single line ( multiple times ) : FName SName - Month D, yyyy ( Then names and dates vary ) I wish to change these to : yyyy-mm-dd - FName SName The system proves a "Find and replace" option using regular expressions. Is anyone able to point me in a suitable direction ? Many, many thanks, Cheers Francesco ____________________________________________________________________________ darktable user mailing list to unsubscribe send a mail to [email protected]____________________________________________________________________________ darktable user mailing list to unsubscribe send a mail to [email protected]
____________________________________________________________________________ darktable user mailing list to unsubscribe send a mail to [email protected]
bin3I4ReNg5QV.bin
Description: PGP Public Key
