|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi,
I'm using sh on Fedora Linux but can easily change shells. How would I scan a directory and all its sub-directories for PDF files larger than 5 MB? Thanks, - Dave |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Wed, 19 Mar 2008 09:05:59 -0700, laredotornado wrote:
> Hi, > > I'm using sh on Fedora Linux but can easily change shells. How would I > scan a directory and all its sub-directories for PDF files larger than 5 > MB? > > Thanks, - Dave If you belive that all pdf files have an extension of ".pdf", then find start_directory -type f -name '*.pdf' -size +5120 -print (fill in the correct start_directory, you can use "." for the current drectory). |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Icarus Sparry schreef:
> On Wed, 19 Mar 2008 09:05:59 -0700, laredotornado wrote: > >> Hi, >> >> I'm using sh on Fedora Linux but can easily change shells. How would I >> scan a directory and all its sub-directories for PDF files larger than 5 >> MB? >> >> Thanks, - Dave > > If you belive that all pdf files have an extension of ".pdf", then > > find start_directory -type f -name '*.pdf' -size +5120 -print > > (fill in the correct start_directory, you can use "." for the current > drectory). > and u can use: find start_directory -type f -iname '*.pdf' -size +5120 -print if you have *.pdf and/or *.PDF and/or *.Pdf files...... -- Luuk |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
laredotornado wrote:
> Hi, > > I'm using sh on Fedora Linux but can easily change shells. How would > I scan a directory and all its sub-directories for PDF files larger > than 5 MB? You have GNU find, thus find /start/dir -iname '*.pdf' -size 5M otherwise: find /start/dir -name '*.pdf' -size 5242880c but the search will not be case-insensitive. -- All the commands are tested with bash and GNU tools, so they may use nonstandard features. I try to mention when something is nonstandard (if I'm aware of that), but I may miss something. Corrections are welcome. |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
pk wrote:
> You have GNU find, thus > > find /start/dir -iname '*.pdf' -size 5M > > otherwise: > > find /start/dir -name '*.pdf' -size 5242880c Ok, sorry but it seems today I leave out pieces without realizing it. Add a "+" in front of each size argument. -- All the commands are tested with bash and GNU tools, so they may use nonstandard features. I try to mention when something is nonstandard (if I'm aware of that), but I may miss something. Corrections are welcome. |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
On Wed, 19 Mar 2008 09:05:59 -0700, laredotornado wrote:
> I'm using sh on Fedora Linux but can easily change shells. I sincerely doubt you're using sh on Fedora: ls -l `which sh` > How would I > scan a directory and all its sub-directories for PDF files larger than 5 > MB? The other solutions posted in this thread use the assumptions that every filename ending with ".pdf" is a PDF file, and also that all PDF files have such a filename. This is simply not true, as PDF files may exist with any name whatsoever and still be PDF files, such as in a browser cache. Use this construct instead using the desired dirname: find dirname -type f -size +5M | xargs file | grep PDF | cut -d: -f1 It's possible to refine the find command if, for instance, your filenames may contain spaces. |
|
![]() |
| Outils de la discussion | |
|
|