Solved

Shell Script Modification, add file metadata

Posted on 2010-08-30
1
392 Views
Last Modified: 2013-12-26
Hi Guys,

I have this script :
find /files/contentstore -mtime +180 > oldfilelist.txt

That script : list all files which have age more than 180 days to oldfilelist.txt.

The "oldfilelist.txt" will contain the full path of the files. For example the contain will be like this :
/var/tmp/calculate1.jpg
/var/tmp/image1.jpg
/root/usr/ben/document1.jpg
/root/view11.jpg

I need some modification to the above script, so each row in "oldfilelist.txt" will  contain :
# file name
# full path
# and modified date

With each metadata separated by tab character. So the "oldfilelist.txt" will contain like this :
calculate1.jpg         /var/tmp/calculate1.jpg         1998-01-31
image1.jpg         /var/tmp/image1.jpg         1978-12-02
document1.jpg         /root/usr/ben/document1.jpg         2010-02-28
view11.jpg         /root/view11.jpg         2009-05-18


Please help. Thanks.
0
Comment
Question by:softbless
1 Comment
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 33563914
find /files/contentstore -mtime +180 | perl -MPOSIX -lne 'print m(.*/(.*)),"\t$_\t",strftime"%Y-%m-%d",localtime((stat)[9])'  > oldfilelist.txt
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Linux Hosting 16 80
fedora linux on laptop - setup sendmail - or some kind of email 5 66
Intel fortran compiler (ifort) 5 59
Linux mount of Windows Shared Now Fails 8 118
Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question