Remove duplicates from tv.ir #16
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This should help speed up the brute force process a bit and prevent the same signal from being sent multiple times.
This ugly command in Bash can be used to de-duplicate the file:
cat tv.ir | grep -v 'Filetype: IR signals file' | grep -v 'Version: 1' | grep -v '#' | sed -z 's/\n/\a/g' | sed 's/name/\nname/g' | awk '!x[$0]++' | sed 's/name/# \nname/g' | sed 's/\a/\n/g' | grep -v '^[[:space:]]*$'Which does the following in this order:
grep -v 'Filetype: IR signals file' | grep -v 'Version: 1': RemoveFiletype: IR signals fileandVersion: 1lines that appear randomly in the file a few times.grep -v '#': Temporarily remove all lines containing#chars.sed -z 's/\n/\a/g': Temporarily replace all\nnewlines with\aspecial character so everything is on the same line with markers where the newlines were.sed 's/name/\nname/g': Add newlines just beforenameto put each full IR signal on their own lines.awk '!x[$0]++': Remove duplicate lines without sorting.sed 's/name/# \nname/g': Add#characters back in above 'name' lines (with a space after the#to match the existing format)sed 's/\a/\n/g': Change\amarkers back to newlines.grep -v '^[[:space:]]*$': Remove blank lines.I know it's kind of involved, but I hope this makes sense. Let me know if I can help clarify anything or if you have any suggestions.