jilostone.blogg.se

Linux find file by name wildcard
Linux find file by name wildcard







linux find file by name wildcard

Some of my earlier posts on the find command are listed below: The next command finds files that are larger than 1 GB: Notice that the command sends all the “permission denied” messages to the /dev/null. Without the addition of the head command in this example, this command would find a lot more empty files – representing the cache and such. To find empty files, use a command like this one: $ find.

linux find file by name wildcard

To find a file by age, use the -mtime option and specify the number of days since the file was modified using a number like +100 (more than 100 days old) or -10 (modified within the last 10 days).

linux find file by name wildcard

You can also look for files by file permissions as in the following example that looks for files that provide all access (777): $ find /usr/bin -name "d*" -perm 777 -ls | head -3ģ4026 0 lrwxrwxrwx 1 root root 9 /usr/bin/dvipdfmx -> xdvipdfmxĢ9934 0 lrwxrwxrwx 1 root root 18 /usr/bin/distro-info -> ubuntu-distro-infoģ3159 0 lrwxrwxrwx 1 root root 6 /usr/bin/dvilualatex -> luatex Notice that the beginning of the file name is included or there would be more files listed. To find files that have group write permissions, you could use a command like this one: $ find /usr/bin -name "net*" -perm -g=w -lsĢ6666 0 lrwxrwxrwx 1 root root 24 /usr/bin/netcat -> /etc/alternatives/netcat Group IDs can be used in place of group names.

linux find file by name wildcard

To find files by group, use the “-group gname” specification. The third example below send output that generates an error (e.g., permission denied) to /dev/null so that it doesn't clutter up the screen. You can specify the username or the user ID. To find files by user, include the “-user uname” specification. This command will remove any file with a “.old” extension from your home directory (including subdirectories). To delete a file, you need to add the -exec rm command as shown below. You probably noticed in the two previous commands that you can list ( -ls means a long listing) or simply display the name of a file ( -print).









Linux find file by name wildcard