The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to scan a file for literal, return 0 or 1 if found? bobk544 Shell Programming and Scripting 11 08-02-2007 04:04 PM
File Scan Dastard Shell Programming and Scripting 2 04-08-2007 03:35 PM
Collecting software inventory superghost UNIX for Advanced & Expert Users 2 11-26-2005 06:01 AM
How to scan only new lines added in file? redlotus72 UNIX for Dummies Questions & Answers 3 04-28-2005 03:34 PM
Software Inventory ViperD UNIX for Dummies Questions & Answers 1 01-22-2001 11:12 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-06-2008
seacros seacros is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 29
File Inventory Scan

Is there such a script out there that will Analyze a folder and subfolders, getting file type utilization and file aging. A CSV file will be created with file information File,Size,Date Created,Last Modified,Last Accessed,Extension,File Type,Owner
A Summary report text file will also be created with analysis by file age and file type.

I got one for my windoZe servers but would like to run something similar on my AIX and Linux boxes.

Thanks
  #2 (permalink)  
Old 03-06-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,715
I did a quick reformat to CSV on this - you get to play with it if it doesn't meet your needs.

Code:
#!/bin/ksh

export string=""
filetime()
{
    perl  -e '
          use POSIX qw(strftime);
          $fmt="%Y-%m-%d:%H:%M:%S ";
          @arr  = stat $ARGV[0];
          print strftime "$fmt", localtime($arr[9]); 
          print strftime "$fmt", localtime($arr[10]);
          print strftime "$fmt", localtime($arr[8]);
          print "$arr[7] $arr[4] $arr[5]\n";         
          
         ' $1
}
cd $1
cwd="$1"
print "files in $(pwd), mtime, ctime, atime, size, uid, gid, filetype"  > file.csv
find . -type f | \
while read filename
do
    export string=""
	filetime $filename | read mtime ctime atime size uid gid
	file $filename | read dummy filetype
    print "$filename, $mtime, $ctime, $atime, $size, $uid, $gid, $filetype"
done >> file.csv
  #3 (permalink)  
Old 03-06-2008
seacros seacros is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 29
I will give it a shot and see what it does.

Thanks
  #4 (permalink)  
Old 03-11-2008
seacros seacros is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 29
I ran it

Ok i ran the script. It seems to hang for some reason. I take a look at the file.csv and it looks complete but the script seems to still be running.
  #5 (permalink)  
Old 03-17-2008
seacros seacros is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 29
New to scripting

How could i append the date & time to the file?

I would like the output to be

hostname_date.csv


Thanks!!!

I am so new at this

Quote:
Originally Posted by jim mcnamara View Post
I did a quick reformat to CSV on this - you get to play with it if it doesn't meet your needs.

Code:
#!/bin/ksh

export string=""
filetime()
{
    perl  -e '
          use POSIX qw(strftime);
          $fmt="%Y-%m-%d:%H:%M:%S ";
          @arr  = stat $ARGV[0];
          print strftime "$fmt", localtime($arr[9]); 
          print strftime "$fmt", localtime($arr[10]);
          print strftime "$fmt", localtime($arr[8]);
          print "$arr[7] $arr[4] $arr[5]\n";         
          
         ' $1
}
cd $1
cwd="$1"
print "files in $(pwd), mtime, ctime, atime, size, uid, gid, filetype"  > file.csv
find . -type f | \
while read filename
do
    export string=""
	filetime $filename | read mtime ctime atime size uid gid
	file $filename | read dummy filetype
    print "$filename, $mtime, $ctime, $atime, $size, $uid, $gid, $filetype"
done >> file.csv
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:58 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0