Solved

Shell Script Modification, add file metadata

Posted on 2010-08-30
1
394 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Application Discovery Service in AWS

In the era of the cloud, customers migrating away from their existing on-premise infrastructure. This requires lots of planning, strategies, and effort to identify their existing resources and determine how best to migrate.  Datacenter migrations happen in four phases -

Question has a verified solution.

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

Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
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.:
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses

615 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