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.

  • 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.

  • Ranger

    Ranger offers a wealth of commands – many with alternatives – and less reliance on a mouse.

  • Areca Backup

    Sometimes you just need to back up a few directories on a computer, not administer a distributed installation or an array of disks. Areca Backup gives you hassle-free backups of individual hard drives.

comments powered by Disqus