Bash – Is it possible to run ls or find and pipe it through stat

bashfindlsstat

Is there a way to run ls or find to get the list of files within a directory and then run stat to get all of the specific information (i.e. File Group, File Name, File Owner, File Size (displayed in K, M, etc.) & Permissions? I was trying something along the lines of:

find .content/media -type f | stat
ls -l .content/media | stat

Answer:

    find ./content/"subdirectory name"/ -type f -exec stat -c '%n : %U : %A : %G : %s' {} +

Best Answer

Use stat on the -exec action of find:

find .content/media/ -type f -exec stat -c '%n : %U : %G : %s' {} +

Change the format sequences of stat to meet your need.

Related Question