Analyzing file metadata in the shell

Taking Stock

© Lead Image © Sebastian Duda, 123RF.com

© Lead Image © Sebastian Duda, 123RF.com

Article from Issue 233/2020
Author(s):

Armed with the right shell commands, you can quickly identify and evaluate file and directory metadata.

Imagine you have a directory with hundreds or even thousands of files (without uniform extensions) that you want to organize. Or maybe you want to know the last access date of a file for backup, forensics, or version management purposes.

Instead of tediously clicking your way through the files in a graphical file manager, a shell script with the test command can help identify filesystem objects as well as provide additional information about the files.

Determining File Type

The file command provides information about a file's contents (Figure 1). Because it tests for patterns in the content, file cannot be misled by file extensions (Figure 2).

[...]

Use Express-Checkout link below to read the full article (PDF).

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Ncdu

    Ncdu adds some GUI-like features to the classic du command.

  • Workspace – Photocrumbs

    Instead of relying on a third-party service for instant photo sharing, you can build your own solution using existing software and a pinch of PHP and Python scripting.

  • Beyond cd

    For decades, cd has been a Linux workhorse, but modern drives sometimes call for more efficient navigation tools. Read on for alternatives for advanced command-line navigation.

  • Housekeeping

    Unneeded files can accumulate on any installation. Here's how to get rid of them on Debian.

  • Swiss File Knife

    Swiss File Knife replaces more than 100 individual command-line tools at once, but it still fits on a USB stick and runs on all major operating systems.

comments powered by Disqus