Skip to content

Instantly share code, notes, and snippets.

@CodeArtha
Created April 10, 2020 15:09
Show Gist options
  • Select an option

  • Save CodeArtha/f0d0285598934e8ea27a82ad913e03b7 to your computer and use it in GitHub Desktop.

Select an option

Save CodeArtha/f0d0285598934e8ea27a82ad913e03b7 to your computer and use it in GitHub Desktop.
Set of bash commands to work with and cleanup wordlists

Clean up wordlists using bash one-liners

The following bash one-liners are useful commands for manipulating wordlists (or any text file). For instance, if you need to remove all blank lines from a file, a one-liner will do the trick. Similarly, if you need to remove duplicate passwords (or text), you can do that too. If you have multiple wordlists, you can also combine them into one large file.

  • Remove duplicates

awk '!(count[$0]++)' old.txt > new.txt

  • Sort wordlist by length

awk '{print length, $0}' old.txt | sort -n | cut -d " " -f2- > new.txt

  • Sort by alphabetical order

sort old.txt | uniq > new.txt

  • Merge multiple text files into one

cat file1.txt file2.txt > combined.txt

  • Remove all blank lines

egrep -v "^[[:space:]]*$" old.txt > new.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment