Quote:
Originally Posted by davidcummings
I am new to the Linux scene and I am using a raspberry Pi to log air traffic radar.
|
Welcome to LQ! You may wish to ask that this thread be moved to the Programming forum for some better exposure; however moderators may also make that determination on their own. Either case, people will still see it so don't be too overly concerned.
Quote:
Originally Posted by davidcummings
Code:
/bin/awk '!_[$1]++' /root/logs/in/radar.txt > /root/logs/in/processed.txt
what I want it to do is go through the radar.txt file, remove any duplicates and save out the result as processed.txt
before i try and run it is the above syntax correct?
|
Correct by my reckoning. I'm not too familiar with awk; however I created a text file containing the following:
I then ran your awk command against it and the result was one of the duplicate "abc" lines was removed. Quick Edit Update: To go further, I thought since me not knowing awk too well that I'd also add a second duplicate, and therefore added another line "123" and it removed both duplicates. So I feel the command as you have it scripted will work properly.
Quote:
Originally Posted by davidcummings
I would also like the file to have a date in the format of yyyy-mm-dd added to the end of each line after a comma:
|
I believe the format you chose is fine, you may also use:
And if you wish a COMMA versus a DASH, then you need to change "radar-" to say "radar,". Personally I prefer the DASH because I think COMMA in a file name is not too great.
Quote:
Originally Posted by davidcummings
and the file saved out as CSV. is this possible?
|
The files are in ... some form of record type? You have performed an awk call to remove duplicate entries, similarly you can use awk, sed, or something to edit entries to place them in CSV form. I would then instead of using a .txt extension, use a .csv extension. The matter there is how difficult it is, but as far as processing a record, you can do this. If you show an illustration of a record and the desired way you'd change it to be comma separated, then people can suggest a command form which will do this.