Recherche de script shell / perl pour capturer l’horodatage du dossier et les fichiers à l’intérieur du dossier

Je cherche un script pour capturer l’horodatage du dossier et les fichiers à l’intérieur du dossier

Exemple: J’ai un dossier Cform12 avec des fichiers à l’intérieur note : note1.txt , note2.rtf , note3.ldt

ls -lrt will generate drwxr-xr-x 5 r12applprd dba 4096 Dec 4 02:31 Cform12 

et

 ls -lrt SCF6761-PROD will generate total 12 -rwxr-xr-x 3 r12applprd dba 4096 Dec 4 02:30 note1.txt -rwxr-xr-x 3 r12applprd dba 4096 Dec 4 02:30 note2.rtf -rwxr-xr-x 26 r12applprd dba 4096 Dec 4 02:31 note3.ldt 

Maintenant, j’ai sortie comme

 Dec 4 02:31 , Cform12 , note1.txt Dec 4 02:31 , Cform12 , note2.txt Dec 4 02:31 , Cform12 , note3.txt 

Besoin d’aide avec le script shell ou perl pour le même.

J’ai créé le script suivant pour aider avec ma question. Merci aux consortingbuteurs pour toutes les directions

 use ssortingct; use warnings; my $dir = '/tmp/'; opendir(DIR, $dir) or die $!; while (my $file = readdir(DIR)) { next unless (-d "$dir/$file"); my $fdir = "$dir/$file"; print "$fdir\n"; my $mtime = (stat $fdir)[9]; $mtime = localtime($mtime); $mtime = echo "$mtime" | awk '{print \$2 , \$3, \$4}' 2 > /dev/ null; chomp($mtime); my @files1 = find $fdir -type f | awk -F "/" '{ print \$NF }'; foreach my $fil (@files1) { print "$mtime,$file,$fil"; } } closedir(DIR); exit 0; 

Je pense que ce script vous aidera si ma compréhension est correcte.

 use ssortingct; use warnings; my $path="/var/inner";#directory absolute path my $mtime=(stat $path)[9]; my $name=`basename $path`; chomp($name); $mtime= localtime($mtime); $mtime=`echo "$mtime" | awk '{print \$2 , \$3, \$4}'`; chomp($mtime); my @files = glob("$path/*"); foreach my $file(@files){ print "$mtime , $name , ".`basename $file`; } 

Le script ci-dessous fait la même chose mais récursivement. c’est ce que tu veux?

 use ssortingct; use warnings; my $path="/export/home/tarumugam/shellshop";#directory absolute path sub rotator{ (my $path)=@_; my $mtime=(stat $path)[9]; my $name=`basename $path`; chomp($name); $mtime= localtime($mtime); $mtime=`echo "$mtime" | awk '{print \$2 , \$3, \$4}' 2> /dev/null`; chomp($mtime); my @files = glob("$path/*"); foreach my $file(@files){ if(-f $file){ print "$mtime , $name , ".`basename $file`; }else{ rotator($file); } } } rotator($path); 

Cherchez-vous quelque chose comme ce qui suit?

 $ stat -c "%x" src; find src -mindepth 1 -maxdepth 1 -exec basename '{}' \; 2013-12-03 22:39:42.911796567 -0500 UndirectedGraphClient.java UndirectedGraph.java Bag.java 

Un guide de script bash pourrait vous aider beaucoup. Jetez un oeil à http://mywiki.wooledge.org/BashGuide ou http://wiki.bash-hackers.org/doku.php ?