|
Prev: un-closed files
Next: trying to recursively get the files' owners and permissions aswell as an md5sum of the data
From: Albretch Mueller on 16 Jun 2008 21:32 I also need the full path to the file, the modification times of the files, which find gives you via: ~ sh-3.1# find /ramdisk -type f -printf "%A@ %C@ %T@" ~ I have tried different things using "find" and "ls" and you can always do it in two steps: ~ sh-3.1# md5sum `find /ramdisk -type f ` | sort ~ and ~ sh-3.1# ls /ramdisk -lRa ~ The closest I have gone (I think) is getting all the info I need (except the md5sum) from ~ sh-3.1# find /ramdisk -type f -printf "%A@ %C@ %T@ %s " -exec ls -l "{}" \; ~ But I haven't been able to succesfully cobble up my second snippet with the last one to get all I want in an efficient way with one piece of Linux/Unix bash/OS-level script, without having to actually code in a high level lang ~ What am I missing, both in my code and conceptually? ~ Thanks lbrtchx
From: Bill Marcum on 17 Jun 2008 10:11 On 2008-06-17, Albretch Mueller <lbrtchx(a)gmail.com> wrote: > > > I also need the full path to the file, the modification times of the files, > which find gives you via: > ~ > sh-3.1# find /ramdisk -type f -printf "%A@ %C@ %T@" > ~ > I have tried different things using "find" and "ls" and you can always do > it in two steps: > ~ > sh-3.1# md5sum `find /ramdisk -type f ` | sort > ~ > and > ~ > sh-3.1# ls /ramdisk -lRa > ~ > The closest I have gone (I think) is getting all the info I need (except > the md5sum) from > ~ > sh-3.1# find /ramdisk -type f -printf "%A@ %C@ %T@ %s " -exec ls -l "{}" \; > ~ > But I haven't been able to succesfully cobble up my second snippet with the > last one to get all I want in an efficient way with one piece of Linux/Unix > bash/OS-level script, without having to actually code in a high level lang > ~ > What am I missing, both in my code and conceptually? > ~ -exec ls -l "{}" \; -exec md5sum "{}" \;
From: Albretch Mueller on 16 Jun 2008 23:46 Stephane CHAZELAS wrote: > find . -type f -printf '%M %n %u %g %T@ %A@ %C@ ' -exec md5sum {} \; Well, I was missing the file length "%s" which I included myself ;-) thank you ~ sh-3.1# find . -type f -printf '%M %n %u %g %T@ %A@ %C@ %s ' -exec md5sum -b {} \; ~ but I still don't get right is the part about making sure that this script is not going to stumble on file names containing spaces and other non-standard characters for that I have read you must use "-print0 | xargs -0" declarations ~ sh-3.1# echo "Humpty Dumpty had a great . . ." > "Humpty Dumpty had a great . . . _ .txt" ~ sh-3.1# ls -l Hum* -rw-r--r-- 1 root root 32 Jun 16 23:27 Humpty Dumpty had a great . . . _ .txt ~ sh-3.1# cat "Humpty Dumpty had a great . . . _ .txt" Humpty Dumpty had a great . . . ~ sh-3.1# find . -type f -print0 | xargs -0 /bin/ls -f -l .. . . -rw-r--r-- 1 root root 32 Jun 16 23:27 ./Humpty Dumpty had a great . . . _ .txt .. . . ~ I don't really know how this "-print0 | xargs -0" business apply to the code example you provided me with. ~ Also, is it safe once you mount a fs that is not native to Linux, say a fs based on MacOS, BSD, FAT32 or ntfs? ~ How do properties of one fs are represented by "find" once you mount it within Linux/Unix? I know the answer to that q will take more than a script fix. Could you, please, point me to some good info pertianing the interplay among these issues? ~ thanks lbrtchx
From: Albretch Mueller on 17 Jun 2008 00:21 Also, I have read somewhere that coding like this: ~ sh-3.1# md5sum `find . -type f -print0 | xargs -0` ~ is better than doing it like: ~ sh-3.1# find . -type f -print0 | xargs -0 md5sum ~ I actually read what this guy said. (S)He didn't say "faster" or "less memory taxing", which are both measurable, but "better" because md5sum is loaded into memory only once ~ I don't really know how the OS handles this, so I am asking ~ lbrtchx
From: Albretch Mueller on 17 Jun 2008 07:53
I think this might be my last question: ~ Say you are gettign now the directories and you want to: ~ 1) Keep the output as specified/pretty-printed in the awk part of the statment, but ~ 2) sort th eoutput based on the last %P field of the output of the find utility ~ Say you have somehting like this: ~ sh-3.1# find . -type d -printf '%T@ %A@ %C@ %P\n' | awk '{print $1"\054"$2"\054"$3"\054""\042"$4"\042"}' ~ 1213703041,1213703341,1213703041,"" 1208899485,1213703341,1208899485,"network" 1208903297,1213703341,1208903297,"network/wiring" 1208899489,1213703341,1208899489,"network/wiring/ethernetcables_files" 1208899489,1213703341,1208899489,"network/wiring/ethernetcables_files/ads_data" 1208899489,1213703341,1208899489,"network/wiring/ethernetcables_files/cm_data" 1208899489,1213703341,1208899489,"network/wiring/ethernetcables_files/ads_data_003" 1208901062,1213703341,1208901062,"network/wiring/cat5e-tutorial.aspx_files" 1208900835,1213703341,1208900835,"network/wiring/CAT5_Ch1_files" ~ after sorting it, it should look like: ~ 1213703041,1213703341,1213703041,"" 1208899485,1213703341,1208899485,"network" 1208903297,1213703341,1208903297,"network/wiring" 1208900835,1213703341,1208900835,"network/wiring/CAT5_Ch1_files" 1208901062,1213703341,1208901062,"network/wiring/cat5e-tutorial.aspx_files" 1208899489,1213703341,1208899489,"network/wiring/ethernetcables_files" 1208899489,1213703341,1208899489,"network/wiring/ethernetcables_files/ads_data" 1208899489,1213703341,1208899489,"network/wiring/ethernetcables_files/ads_data_003" 1208899489,1213703341,1208899489,"network/wiring/ethernetcables_files/cm_data" ~ sh-3.1# find . -type d -printf '%P\n' | sort ~ network network/wiring network/wiring/CAT5_Ch1_files network/wiring/cat5e-tutorial.aspx_files network/wiring/ethernetcables_files network/wiring/ethernetcables_files/ads_data network/wiring/ethernetcables_files/ads_data_003 network/wiring/ethernetcables_files/cm_data ~ How can you sort then the output? ~ thanx lbrtchx |