Click here to get back home

script to find the files with very long names

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
script to find the files with very long names pui ming Wong 06-12-2006
Posted by Tad McClellan on June 12, 2006, 9:08 am
Please log in for more thread options
>>
>> [snip]
>>
>> > if I print "$1\n",
>> > the file prints just fine. But, if I do something like print "$1 after
>> > \n", the whole output is messed up. If I print "before $1\n", nothing
>> > prints at all. If I print "before $1 after\n", only after prints.
>>
>> not really sure, but could be a rogue "\r" in $1,


> There
> is a rogue carriage return (0xd) in the string

> Is there something I can do to deal with this
> situation?


Repair the corrupted file:

perl -p -i -e 'tr/\r//d' bad_file


--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas

Posted by Ed Morton on April 26, 2008, 2:00 am
Please log in for more thread options
On 6/12/2006 2:34 AM, pui ming Wong wrote:
> My objective is to go down the current directory
> and have the system tells me which files have their names
> longer than say 26 characters
>
> i think mixing the unix find command
> with some other commands might do it.
> But a perl script might do it more tidily and faster ?

find . -name "??????????????????????????*"

That's 26 question marks, or if you prefer to specify a value:

find . -name "$(printf "%26s*"|tr ' ' '?')"

Regards,

        Ed.


Posted by Jürgen Exner on April 26, 2008, 10:08 am
Please log in for more thread options
>On 6/12/2006 2:34 AM, pui ming Wong wrote:
>> My objective is to go down the current directory
>> and have the system tells me which files have their names
>> longer than say 26 characters
>>
>> i think mixing the unix find command
>> with some other commands might do it.
>> But a perl script might do it more tidily and faster ?

File::Find with a simple
        {print if lenght > 26}
as the wanted function should do nicely.

jue

Posted by John W. Krahn on April 26, 2008, 1:47 pm
Please log in for more thread options
J=FCrgen Exner wrote:
>> On 6/12/2006 2:34 AM, pui ming Wong wrote:
>>> My objective is to go down the current directory
>>> and have the system tells me which files have their names
>>> longer than say 26 characters
>>>
>>> i think mixing the unix find command=20
>>> with some other commands might do it.
>>> But a perl script might do it more tidily and faster ?
>=20
> File::Find with a simple
>         {print if lenght > 26}
> as the wanted function should do nicely.

s/lenght/length/;


John
--=20
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall

Posted by David Combs on May 19, 2008, 6:01 pm
Please log in for more thread options
>On 6/12/2006 2:34 AM, pui ming Wong wrote:
>> My objective is to go down the current directory
>> and have the system tells me which files have their names
>> longer than say 26 characters
>>
>> i think mixing the unix find command
>> with some other commands might do it.
>> But a perl script might do it more tidily and faster ?
>
>find . -name "??????????????????????????*"
>
>That's 26 question marks, or if you prefer to specify a value:
>
>find . -name "$(printf "%26s*"|tr ' ' '?')"
>
>Regards,
>
>        Ed.
>

If 26 is what you *really* want to do, isn't there nowadays
a \ suffix that will do it? (At least that's what
works in emacs.)

David



Similar ThreadsPosted
any script to find renamed wmf files? January 2, 2006, 12:06 pm
Script to find largest files November 1, 2007, 10:15 am
Rename files using directory names November 15, 2007, 8:33 am
rename not working on files with accents in names April 24, 2005, 12:04 am
How long is too long for cgi script? April 22, 2005, 12:07 pm
File::Find dies on directory paths which are too long March 13, 2007, 2:53 pm
How to find all the strings in a long that are at most of n different characters of a test string? November 19, 2008, 6:34 pm
Perl Script to change IPs to DNS Names November 16, 2006, 10:56 am
File slurp takes a long time on some files November 22, 2004, 6:43 pm
creating variable names within a perl script July 16, 2006, 3:14 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap