Skip to content

Conversation

@c-nagy
Copy link
Contributor

@c-nagy c-nagy commented Jul 7, 2022

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:

  1. grep -v 'Filetype: IR signals file' | grep -v 'Version: 1' : Remove Filetype: IR signals file and Version: 1 lines that appear randomly in the file a few times.
  2. grep -v '#': Temporarily remove all lines containing # chars.
  3. sed -z 's/\n/\a/g': Temporarily replace all \n newlines with \a special character so everything is on the same line with markers where the newlines were.
  4. sed 's/name/\nname/g': Add newlines just before name to put each full IR signal on their own lines.
  5. awk '!x[$0]++': Remove duplicate lines without sorting.
  6. sed 's/name/# \nname/g': Add # characters back in above 'name' lines (with a space after the # to match the existing format)
  7. sed 's/\a/\n/g': Change \a markers back to newlines.
  8. 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.

c-nagy added 4 commits July 7, 2022 06:44
With better initial '#' character removal. Updated command in pull request comment.
This signal had "Filetype: IR signals file" appended to the "command:" line. See line 2983 in original file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants