- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Need a script for finding bad file names.
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-11-2004 12:20 AM
тАО03-11-2004 12:20 AM
The problem is that I have users who continue to write bad sqls. These bad sqls created erroronous files with bad file names. These bad file names have been know to cause my ingite backup tape creation to fail. Therefore, I need to make every attempt to ensure that these bad file names are not on the server prior to creating the ignite. To add to the problem, I need to search through all the directories for these files, and the system has thousands of directories. What I am looking for is a script that can search through all the directories for bad file names. A bad file name is any that contains a character other than [a-z],[A-Z],[0-9],".","-", and "_". In otherwords files that contain any of the following "!@#$%^&*()+=[]{}<>?:;~ and `. Plus I have found files that contain a space and others that have special symbols like greek letters. Not sure how that happens, but it does. Below is a perl script that someone gave me a while back and it works for finding the special symbols files, greek letters, but the script doesn't find files that contain the previously mentioned listing, i.e. "!@#$%..." Can any one help? I bet all this will take is to add the previously mentioned list to the filter below, but I am unfamiliar with PERL and don't know how to code it.
Perl Script
$filter = "[a-zA-Z0-9_\.\/\ -\s\{}]";
# regex filter
print "What path to search? (i.e. /var/): ";
$inp_dir =
chop $inp_dir;
# remove newline from input
@files = `find $inp_dir`;
# store file list
foreach $line (@files) {
@chars = split(/ */, $line);
# break up each line
foreach $letter (@chars) {
if ($letter !~ /$filter/){
# find bad characters
print $line;
undef @chars;
} #end if
} #end foreach
} #end foreach
Please help.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-11-2004 12:25 AM
тАО03-11-2004 12:25 AM
Re: Need a script for finding bad file names.
These can be seen with vis:
# ll | vis
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-11-2004 12:35 AM
тАО03-11-2004 12:35 AM
Re: Need a script for finding bad file names.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-11-2004 12:52 AM
тАО03-11-2004 12:52 AM
Re: Need a script for finding bad file names.
find / -print | vis | grep '\\'
This will find any file with (for example) ^H or ^C in the filename, reporting them in the ascii format
I created a test file called t^C^Hest
The above find command shows it as
t\003\best
- Tags:
- find
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-11-2004 01:13 AM
тАО03-11-2004 01:13 AM
SolutionHow did it fail for you?
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=499770
Here it is again in two flavors...
RUn stand alone with optional directory argument:
#!/bin/perl
$dir = shift(@ARGV);
$glob = ($dir) ? $dir . "/*" : "*";
print "- $glob -\n";
while (<${glob}>) {
$files++;
$file = $_;
s/\w+//g;
s/[\.\-\/]//g;
print $dirty++ . " $file\n" if ($_ ne "");
}
printf "Found $files files, $dirty with a problem in the name\n";
And the next where you run it at the end of a pipe like:
ls | check_names
or
find /somedir | checknames
#!/bin/perl
while (<>) {
chop;
$files++;
$file = $_;
s/\w+//g;
s/[\.\-\/]//g;
print $dirty++ . " $file\n" if ($_ ne "");
}
printf "Found $files files, $dirty with a problem in the name\n";
Cheers,
Hein.
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-11-2004 03:16 AM
тАО03-11-2004 03:16 AM
Re: Need a script for finding bad file names.
The first perl script gave me the following results.
- * -
Found 87 files, with a problem in the name
The second perl script game me the following results. It listed the files.
...
filename
filename2
Found 126239 files, 821 with a problem in the name
Which is great, but I was unaware of how often the following characters },!,@,+,= were used in system file names.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-11-2004 03:26 AM
тАО03-11-2004 03:26 AM
Re: Need a script for finding bad file names.
I now see I managed to post a debug version.
In the first script remove the line: "print "- $glob -\n";
Both scripts could use an explicit $dirty=0;
It would be trivial to add say a "+" (from lost+found :-) to the second replace list.
Cheers,
Hein.