32_find.sh (1429B)
1 #!/bin/sh 2 # 3 # find is used to find just about anything 4 # 5 # $ find exercises/ -name 01_echo.sh 6 # 7 # There are many filters and regex you can use to help in your searches 8 # 9 # $ find ~ -type d -iname git 10 # 11 # the command above is used to find a directory named "git", including 12 # all uppercase and lowercase finds 13 # 14 # $ find [location] [options] [name] 15 # 16 # [location] 17 # anywhere you want with permission 18 # 19 # [options] 20 # -type x replace 'x' with f if you are looking for files, d for 21 # directories, l for links, b for blockdevices 22 # -executable can be added to search for it 23 # -name looks for that exact name 24 # -iname case insensitive 25 # -size +100M files larger than 100MB 26 # -1G small than 1GB 27 # -empty empty files 28 # -mtime -1 modified in the last day 29 # -amine -10 accessed in the last 10 minutes 30 # 31 # -prune requires more explanation 32 # $ find . -name tests -type d -prune -o -type f -print 33 # 34 # the find command looks through the current dirctory. If it name 35 # matches with 'tests', it will skip a recursion into it and move on 36 # the '-o' is the or in the command. To either skip or to print out each 37 # file. The -print at the end makes sure that the dir tests/ is not 38 # printed out. 39 # 40 # [name] 41 # includes regex 42 # 43 # Have the find command list out all files in the shelllings/ repo 44 # that have a 'oo' in the file name, exclude the .git/ folder. 45