It is a SED issue.
I am working in Quartz Composer (Mac OSX) script to:
I think this would be so simple. At this moment, I have this done in QC, and it is almost working. But I have issues with the SED commands in both getFileName.sh and getLastLineOfLog.sh
getFileName.sh
#!/bin/bash
cd /Users/Me/
/bin/echo `ls -tr *.log | tail -1`
What I need here is to open the last .log file, with this name structure 127.0.0.1,NUMBER.log being the NUMBER section a 5 digits number. The higher the number, the newer the .log file. Now, it opens just the first .log file.
Do you know how to write in SED the right commands for doing that, please?
getLastLineOfLog.sh
#!/bin/bash
/usr/bin/tail -1 /Users/Me/$1 | sed 's/^.\{24\}//' > /Users/Me/$1.log
echo `/usr/bin/tail -1 /Users/Me/$1.log`
In this second file, I have tried to get the last file of the loaded .log and echo it without its 24 first characters. It works, but creating a new .log.log. (etc.) file each time the function passes, thing that I would like to avoid.
Is it necessary to output the results of the SED commands to a new file? How could it be done as simple as possible?
Thank you in advance.
if you want to sort by the filename:
ls *.log | sort -t, -k2 -n | tail -1