Solved

Shell Script Modification, add file metadata

Posted on 2010-08-30
1
390 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
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…

785 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