![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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 |
|
||||
|
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
|
|
||||
|
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:
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|