Last active
October 10, 2022 00:05
-
-
Save fiddyschmitt/ca9da54207f272203a9f0d9d35a91cac to your computer and use it in GitHub Desktop.
Linux find commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --Filename, size, creation date, last modification date, | |
| find "`pwd -P`" 2>/dev/null -printf "%p|%s|%B@|%T@|%y\n" | |
| --printf descriptions | |
| https://www.gnu.org/software/findutils/manual/html_mono/find.html#Time-Formats | |
| https://www.codedodle.com/find-printf.html | |
| --hashes | |
| find -type f -exec sha256sum "{}" + | tee hashes-sha256.txt | |
| --sorted by hashes | |
| find . -type f -print0 | sort -z | xargs -r0 sha256sum | tee hashes-sha256.txt | |
| --find files (that have spaces) that contain some text but not other text | |
| find "`pwd -P`" -iname "*.xml" -print0 | xargs -0 grep -FlisZ "foo" | xargs -0 grep -FLis "bar" | |
| --find files, ignoring errors | |
| find /share/branches/ -iname 'index*' 2>/dev/null | |
| --find certain files that contain some text | |
| find -iname "*.xml" 2>/dev/null | xargs grep -Flis "<DomainId>" | |
| --multiple extensions | |
| find -regextype posix-extended -regex '.*\.(java|cpp)' 2>/dev/null | xargs grep -Flis "<DomainId>" | |
| --most used | |
| find "`pwd –P`" –iname "*.txt" –type f –print0 | xargs -0 grep –Flis "hello" | |
| --order by last modified date | |
| find "`pwd -P`" -iname "*.zip" -printf "%T+\t%p\n" | sort | |
| --sort contents of file alphabetically, ignore case | |
| sort "files_unsorted.txt" --ignore-case > "files_sorted.txt" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment