Less known ls arguments

   |   2 minute read   |   Using 392 words

Less known ls command arguments

  1. -I, –ignore=PATTERN Diving into directories cluttered with temporary or peripheral files can be daunting. The –ignore flag allows you to filter out files matching a specific pattern, simplifying your directory listings and focusing on the files that matter.

  2. -d, –directory Ever wanted to list directories themselves rather than their contents? The -d flag does exactly that, enabling you to treat directories as regular files. This can be particularly useful in scripts or when piping output to other commands.

  3. -R, –recursive While not obscure, the power of the -R flag is often underestimated. It recursively lists all subdirectories, providing a comprehensive overview of a directory’s hierarchy. This flag can be invaluable for a deep dive into complex directory structures.

  4. -t Order is paramount in managing files. The -t flag sorts files by modification time, newest first. When coupled with -l, it not only reveals the details but also the temporal sequence of your files, offering insights into your most recent work.

  5. –time=WORD The –time flag takes customization a step further, allowing you to sort files based on different time criteria: atime, access, use, ctime, or status. Tailoring your listings by specific time attributes can streamline file management and retrieval processes.

  6. –time-style=STYLE Aesthetic preferences vary, and so does the way we like to view timestamps. With –time-style, customize the display format of time to suit your needs, whether it’s full-iso, long-iso, iso, locale, or your own custom format.

  7. -i, –inode Every file in a Unix-like system is identified by an inode number. By using the -i flag, you can display these inode numbers alongside the filenames, a feature that can be crucial for filesystem management and troubleshooting.

  8. -L, –dereference Symlinks are a staple in Unix and Linux, but sometimes you need to see the file at the end of the link rather than the link itself. The -L flag resolves symlinks, listing the files they point to instead of the links.

  9. –hide=PATTERN Similar to –ignore, but specifically geared towards hiding files matching the pattern from the listing. This can be especially useful when combined with the -a flag to exclude certain hidden files from your view.

  10. -X Files come in various types and extensions. Sorting them alphabetically by entry extension using the -X flag can aid in quick identification and access, particularly in directories filled with diverse file types.



denis256 at denis256.dev