Solved

Shell Script Modification, add file metadata

Posted on 2010-08-30
1
389 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
Comment Utility
find /files/contentstore -mtime +180 | perl -MPOSIX -lne 'print m(.*/(.*)),"\t$_\t",strftime"%Y-%m-%d",localtime((stat)[9])'  > oldfilelist.txt
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

763 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now