Question

Edit: Instead of tossing out the duplicate data I want it to "overwrite" the duplicate data, meaning leave the data but update the timestamp

Problem 1:

I have a command line as follows,

tail -f /some/file.log | awk '$2>10 (if (!($1 in a)) print $1, strftime("%Y-%m-%d %H:%M:%S"); a[$1]=1 ;system("")}' > /some/filteredfile.log

However, I would like the output from this to only add the text to file if it isn't already there (in the 1st column), and if it is there, update the timestamp (in the second column)

Was it helpful?

Solution

Try:

tail -f /some/file.log | awk ' $2>10 {if (!($1 in a)) print $1; a[$1]=1; system("")}' > /some/filteredfile.log

OTHER TIPS

One problem two part may be:

tail -f file.txt | awk -v date="$(date +"%Y-%m-%d-%h%m%s")" '$2>10 {print date, $1; system("")} ' > output.log

It should solve your 2nd part, working for me.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top