Skip to content
loading...

re: Byte Size: Changing Habits with the Command Line VIEW POST

FULL DISCUSSION
 

ls is good for finding stuff when you basically know where the target "stuff" is. If you want real power, look at the find command.

  • Want to see all the files you've modified in the last 3 days? find <DIR> -mtime -3
  • Disk is getting full and you want to identify disused files for archival? find <DIR> -mtime +&lt;DAYS>
  • Want to know where various DVD images you downloaded got to? find <DIR> -type f -name "*.iso"
  • Want to find all files that are actually symlinks? find <DIR> -type l
  • Want to see what files have the world-write permission set on them? find <DIR> -perm /0002 -type f

The possibilities are near endless, especially once you add find's -exec built-in function or pipeline your find to other tools via xargs (e.g., find <DIR> -type f | xargs grep -l <STRING> will provide you a list of files that contain a given string).

 

This is incredibly helpful! Thanks so much, I'm going to try these out ASAP!

code of conduct - report abuse