Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Operation request: Unique/Sort lines based on part of it #1813

Open
w4po opened this issue May 17, 2024 · 0 comments
Open

Operation request: Unique/Sort lines based on part of it #1813

w4po opened this issue May 17, 2024 · 0 comments

Comments

@w4po
Copy link

w4po commented May 17, 2024

Summary

  • Ability to sort input lines based on regex, or even better if we can sort the whole input lines based on Subsection
  • Ability to get unique lines based on part of a line.

I want to get the most recent backup file of each database:

Example Input

ABC_backup_2024_04_19_030015_4199663.bak
ABC_backup_2024_04_26_031328_7771579.bak
ABC_backup_2024_05_10_030015_4434976.bak
ABC_backup_2024_05_03_030022_5120774.bak
KQMO_backup_2024_04_19_030014_8992595.bak
KQMO_backup_2024_04_26_031328_2733774.bak
KQMO_backup_2024_05_03_030021_8090927.bak
KQMO_backup_2024_05_10_030014_9279748.bak
QWERTY_backup_2024_04_19_030015_5155445.bak
QWERTY_backup_2024_04_26_031328_8747284.bak
QWERTY_backup_2024_05_10_030015_5372286.bak
QWERTY_backup_2024_05_03_030022_6214310.bak

Example Output

ABC_backup_2024_05_10_030015_4434976.bak
KQMO_backup_2024_05_10_030014_9279748.bak
QWERTY_backup_2024_05_10_030015_5372286.bak

For me to do that in the current version of CyberChef, I had to do the following steps:

  1. swap the DB name with the date
  2. convert date to timestamp
  3. sort numeric
  4. convert back timestamp to date
  5. swap back date with the name
  6. using regex Extract unique lines (last occur of each name [the lines are sorted based on date already])

Here is my attempt: Recipe

@w4po w4po added the operation label May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant