asfencat.blogg.se

Unix find file in subdirectories
Unix find file in subdirectories




unix find file in subdirectories

It is used to specify a specific path to search. path option is like the -wholename option. c files except the ones present in the C directory without using prune: inode number is specified using the inum option.ġ5. Same, but using the inode number of the temp directory. Using inum and prune to exclude directory in-place of name option: name temp -exec test '' is the file found by the findġ4. Using exec and prune to exclude directory in-place of name: Note: The path specified in the wholename option should be relative to the search path specified, not the absolute path.ġ3. In case, if the requirement is to prune a specific temp directory, then you can give the path of the directory itself. The earlier approaches will pruneĪll the temp dierctories. Say, in your directory tree, there might be more than one temp directory. wholename "./temp" -prune -o -perm 644 -printįind has a switch with the name 'wholename'. Same using the wholename option and prune to exclude directory: permission 644 indicates files with permission rw-r-r-.ġ2. perm option in find allows to find files with specific permissions. Find all files whose permission is 644 except the ones present in the temp directory: Using the -type f option, find will find only the regular files alone.ġ1. type d -name temp -prune -o -type f -mtime -1 -print Find only regular files modified in the last one day except the ones present in the temp directory: Usage of mtime makes find to search for files modified in the last day alone.ġ0. type d -name temp -prune -o -mtime -1 -print Find all files modified in the last one day except the ones present in the temp directory:

unix find file in subdirectories

To specify multiple directories with the -name option, -o should be used as an OR condition.ĩ. type d \( -name C -o -name temp \) -prune -o -name "*.c" -print c files except the ones present in the C and temp directory: c files are found and printed except the ones present in C.Ĩ. The 1st part prunes out the C directories. type d -name C -prune -o -name "*.c" -print c files except the ones present in the C directory: The only difference here is the print statement being present in the first half as well.ħ. Also print the temp directories if present: Find all the files except the ones under the temp directory. Printed from the 1st part of the condition.Ħ. In this find command, -print is associated in the other side of the OR condition, and hence nothing will get Print files only on explicit print instructions. However, once the -print option is specified, it will By default, the find command prints all the files matching the criteria. Due to the OR condition, all the other files(files other than the ones present in the tempĭid you expect the temp directory to get printed? In the last example, we saw the directories.






Unix find file in subdirectories