Skip to content

Instantly share code, notes, and snippets.

@gwpl
Last active May 25, 2017 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gwpl/20aa3c8c1daa98619cd8f733a0326cb5 to your computer and use it in GitHub Desktop.
Save gwpl/20aa3c8c1daa98619cd8f733a0326cb5 to your computer and use it in GitHub Desktop.
Generate .csv formatted basic metadata, fast to obtain, but allowing heuristics for syncing files or initial eastimation of backup/sync coverage. ( And yes, I know that this find command will not properly encode filenames containing quotes according to csv standard )
#!/bin/bash
# Generate .csv formatted basic metadata, fast to obtain, but allowing heuristics for syncing files or initial eastimation of backup/sync coverage.
fullpath="${1:-$PWD}"
dest="${2:-"$fullpath"/basic_files_metadata.csv.gz}"
hostname="${3:-"$(hostname)"}"
echo "find \"${fullpath}\" -type f -exec stat --format=\"%i,%Y,%s,%m,%n\" \"{}\" \\; > \"${dest}\""
echo "Progress in lines generated:"
(echo "inode,modification_ts,size,hostname,mount,path";
find "${fullpath}" -type f -exec stat --format="%i,%Y,%s,${hostname},%m,%n" "{}" \;
) | pv -l | gzip > "${dest}"
echo -n Finished:
ls -lha "${dest}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment