LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-23-2008, 07:55 AM   #1
webaccounts
Member
 
Registered: May 2008
Location: Columbus Ohio
Distribution: CentOS 5.9/6.4 x64
Posts: 44

Rep: Reputation: 19
Script doesn't recognize wierd characters


Hopefully someone knows whats wrong with this script. I have a game server that basically deletes any player files that haven't been modified in atleast 90 days.

Code:
#!/bin/sh
# Running this script will remove all player files older than 90 days.
echo ;date
echo "Cleaning up 90 day old player files....."
find -type f -mtime +90
# Actual deletion:
find -type f -mtime +90 -name "*.bic" -exec rm -f {} \;
echo "Cleaning is done."
It works except people with funny names don't work.
For an example:

Code:
./Art?_?miS/?_?artemide?_?.bic
Just wanted to see if there is a way for the above script to catch these wierd characters.

Thanks
Klesla
 
Old 05-23-2008, 08:20 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Instead have 'find' -printf the inode of the file?
 
Old 05-23-2008, 08:28 AM   #3
webaccounts
Member
 
Registered: May 2008
Location: Columbus Ohio
Distribution: CentOS 5.9/6.4 x64
Posts: 44

Original Poster
Rep: Reputation: 19
Quote:
Originally Posted by unSpawn View Post
Instead have 'find' -printf the inode of the file?
What do you mean by that?

Sorry, just learning scripting. The help file says -printf FORMAT but doesn't say what it does or how to add it.
 
Old 05-23-2008, 08:40 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Something like 'find -type f -mtime +90 -name "*.bic" -printf "%i\n" | xargs -iI find -inum 'I' -exec rm {} \;'.
 
Old 05-23-2008, 10:04 AM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Would it work if you enclosed the braces in single quotes:

Code:
find -type f -mtime +90 -name "*.bic" -exec rm -f '{}' \;
Another option is to use the NULL character to separate arguments:
Code:
find -type f -mtime +90 -name "*.bic" -print0 | xargs -0 rm -f
 
Old 05-23-2008, 12:34 PM   #6
webaccounts
Member
 
Registered: May 2008
Location: Columbus Ohio
Distribution: CentOS 5.9/6.4 x64
Posts: 44

Original Poster
Rep: Reputation: 19
Thanks for the posts. However all 3 didn't work.
 
Old 05-24-2008, 11:26 AM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by webaccounts View Post
all 3 didn't work.
"Didn't work" is not the kind of output I can deal with.
Try posting exactly what the command returns instead.
 
Old 05-27-2008, 09:29 AM   #8
webaccounts
Member
 
Registered: May 2008
Location: Columbus Ohio
Distribution: CentOS 5.9/6.4 x64
Posts: 44

Original Poster
Rep: Reputation: 19
Sorry. It just doesn't do anything new. But here is the output.

Code:
[root@mars servervault]# find -type f -mtime +90
./Art?_?miS/?_?artemide?_?.bic
./The DC DC/??z?58555g.bic
./The DC DC/?c?7?z15r554.bic
./The DC DC/?z???hn8.bic
./The DC DC/c??0a.bic
./Alastorgame/?r?__kll.bic
./Alastorgame/?r?kll6.bic
./Alastorgame/?r?kll5.bic
./Alastorgame/?rnkillh?h.bic
./Alastorgame/?r?kll.bic
[root@mars servervault]# find -type f -mtime +90 -name "*.bic" -printf "%i\n" | xargs -iI find -inum 'I' -exec rm {} \;
[root@mars servervault]# find -type f -mtime +90
./Art?_?miS/?_?artemide?_?.bic
./The DC DC/??z?58555g.bic
./The DC DC/?c?7?z15r554.bic
./The DC DC/?z???hn8.bic
./The DC DC/c??0a.bic
./Alastorgame/?r?__kll.bic
./Alastorgame/?r?kll6.bic
./Alastorgame/?r?kll5.bic
./Alastorgame/?rnkillh?h.bic
./Alastorgame/?r?kll.bic
[root@mars servervault]#
All 3 scripts I tried and all 3 didn't get those wierd ones.
 
Old 05-27-2008, 11:18 AM   #9
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Can you at least "find -inum $inode -exec rm {} \;" manually, where "$inode" is one of the inode numbers from running "find -type f -mtime +90 -name "*.bic" -printf "%i\n"? What is your locale? Does "find -type f -mtime +90 -name "*.bic" -print0 | xargs -0 -iX /bin/ls --quoting-style=c --show-control-chars -1iQ 'X'" show different output from what you posted above?
 
Old 05-27-2008, 12:37 PM   #10
webaccounts
Member
 
Registered: May 2008
Location: Columbus Ohio
Distribution: CentOS 5.9/6.4 x64
Posts: 44

Original Poster
Rep: Reputation: 19
Quote:
Originally Posted by unSpawn View Post
Can you at least "find -inum $inode -exec rm {} \;" manually, where "$inode" is one of the inode numbers from running "find -type f -mtime +90 -name "*.bic" -printf "%i\n"? What is your locale? Does "find -type f -mtime +90 -name "*.bic" -print0 | xargs -0 -iX /bin/ls --quoting-style=c --show-control-chars -1iQ 'X'" show different output from what you posted above?
I tried your above command but it didn't them either. I did find out something though.

The -name "*.bic" isn't finding them.

Code:
[root@mars servervault]# find -type f -mtime +90
./Art?_?miS/?_?artemide?_?.bic
./The DC DC/??z?58555g.bic
./The DC DC/?c?7?z15r554.bic
./The DC DC/?z???hn8.bic
./The DC DC/c??0a.bic
./Alastorgame/?r?__kll.bic
./Alastorgame/?r?kll6.bic
./Alastorgame/?r?kll5.bic
./Alastorgame/?rnkillh?h.bic
./Alastorgame/?r?kll.bic
[root@mars servervault]# find -type f -mtime +90 -name "*.bic"
[root@mars servervault]#
So I wonder why * isn't treated as a wild card like it should be.
 
Old 05-27-2008, 01:15 PM   #11
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Have you tried a
Code:
find -type f -mtime +90  -exec rm -f '{}' \;
?

It should be sane since in your search for that mtime only bic
with funny characters showed up...


Cheers,
Tink
 
Old 05-27-2008, 01:57 PM   #12
webaccounts
Member
 
Registered: May 2008
Location: Columbus Ohio
Distribution: CentOS 5.9/6.4 x64
Posts: 44

Original Poster
Rep: Reputation: 19
Quote:
Originally Posted by Tinkster View Post
Have you tried a
Code:
find -type f -mtime +90  -exec rm -f '{}' \;
?

It should be sane since in your search for that mtime only bic
with funny characters showed up...


Cheers,
Tink
That does work. I was just hoping to keep it to bic files only because sometimes I keep backup player files there. It seems I might have to resort to that though unless I can get this to work.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Wierd CVS checkout problem from CGI perl script spadesmaster Linux - Software 0 04-27-2007 04:19 PM
KDE, foreign language keyboard give wierd characters like "¿qué tal estás?" lefty.crupps Linux - Software 2 07-06-2006 12:17 PM
wierd characters in external disk name after Gnome automount nsk078 Linux - General 0 11-27-2004 05:32 PM
wierd characters in /var/log/wtmp mindfestival Linux - Newbie 2 04-22-2004 01:02 AM
Wierd characters when PuTTY connects to Slack Kocil Slackware 4 09-12-2003 08:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration