0

I want to search both the path and file names for words, and then get their size.

Using locate gets me all of the files I want but not their size:

locate -A wordlist oracle

/usr/share/dirb/wordlists/vulns/oracle.txt
/usr/share/metasploit-framework/data/wordlists/hci_oracle_passwords.csv
/usr/share/metasploit-framework/data/wordlists/oracle_default_hashes.txt
/usr/share/metasploit-framework/data/wordlists/oracle_default_passwords.csv
/usr/share/metasploit-framework/data/wordlists/oracle_default_userpass.txt
/usr/share/sparta/wordlists/oracle-default-userpass.txt
/usr/share/wfuzz/wordlist/vulns/oracle9i.txt

Using Find, I can search for file names, and get their size like so;

find /usr/share/ -name '*oracle*' -exec ls -lh {} \;

However, this finds more then I want. How do I filter find such that the path (or file) has the word "wordlist" in it? Or if thats not possible how do I pipe/feed/automate getting the size of the locate results?

  • 1
    Have you tried find /usr/share/ -name '*wordlist*/*oracle*' -exec ls -lh {} \;? – Andrew Shum Jan 19 '18 at 17:29
  • @AndrewShum unfortunately find -name doesn't work like that (as it will tell you if you try: Unix filenames usually don't contain slashes...). However you could try find /usr/share -path '*wordlist*' -name '*oracle*' or even -path '*wordlist*/*oracle*' – steeldriver Jan 19 '18 at 18:02
0
ls -ldh `locate -A wordlist oracle`

or

ls -ldh $(locate -A wordlist oracle)

I added the d option in ls to take care of folders (if any).

  • Using backticks is discouraged, as they aren't nestable, and, depending on the font, harder to identify than the preferred $(...) construct. – user unknown Feb 3 '18 at 7:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.