LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-24-2010, 04:03 PM   #16
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195

Quote:
Originally Posted by NickJH View Post
Have we still got the meta-character problem?
Sure looks like it and sorry for not catching that earlier. Hopefully the script suggestion without the find has provided a workaround. If not we can escape the metacharacters.
 
Old 05-24-2010, 07:45 PM   #17
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,550

Rep: Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898
Just thought I would chime in, although catkin is a bit more a guru than me, but i was looking at the lines from your 'ls' and wondered if maybe the issue
could be resolved by searching for something other than the name of the show which is the same between both?

So we have:
Quote:
-rw------- 1 transmission allusers 14936 May 22 11:27 /home/transmission/.config/transmission-daemon/torrents/Alvin and the Chipmunks - The Squeakquel[2009.DvDRiP[NoRaR]L33t - bittoxic.8eaa61dc40f690ea.torrent
-rw------- 1 transmission allusers 31606 May 23 12:40 /home/transmission/.config/transmission-daemon/torrents/Alvin.and.the.Chipmunks.The.Squeakquel.2009.NORDiC.DVDR-HiGH.f836de6d3a3497cf.torrent
Where the second is to be kept but the first deleted. I also noted that the first has the string "bittoxic" but not the second. Maybe if you used this word with asterixes
it could solve the issue of lots of escaping??

Hope this is not a wildly useless tangent.
 
Old 05-25-2010, 01:11 AM   #18
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by grail View Post
... although catkin is a bit more a guru than me ...
What is your evidence for that? What are the symptoms?

In support of the contrary view I point out that I overlooked find -name metacharacters!

Chime away!

In this case, though, I don't think your suggestion is workable because the file names are not known in advance. I'm hoping that the alternative script without find -name will solve the requirement.
 
Old 05-25-2010, 05:09 AM   #19
NickJH
LQ Newbie
 
Registered: Mar 2009
Distribution: ClarkConnect CE5.0
Posts: 19

Original Poster
Rep: Reputation: 0
Smile [SOLVED] Delete files with complex filenames with a script

Thanks for your help. Catkin's solution worked. I still don't fully understand why but I'll have to research that.

@grail, unfortunately none of the filename can be predetermined. With the two files I listed, one could have completed downloading and is therefore the one I want to delete, the other could still be downloading. The only way I know if a file has completed downloading is that it appears in $DOWNLOADPATH without all the garbage on the end. The file name is up to the torrent seeder and is out of my control.

Last edited by NickJH; 05-25-2010 at 08:44 AM. Reason: Mark as solved
 
Old 05-25-2010, 05:26 AM   #20
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,550

Rep: Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898
No probs ... glad you have a solution
Don't forget to mark as SOLVED.
 
Old 05-25-2010, 06:54 AM   #21
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by NickJH View Post
Thanks for your help. Catkin's solution worked. I still don't fully understand why but I'll have to research that.
You could look at filename expansion.
 
Old 05-25-2010, 09:26 PM   #22
dasy2k1
Member
 
Registered: Oct 2005
Location: 127.0.0.1
Distribution: Ubuntu 12.04 X86_64
Posts: 960

Rep: Reputation: 35
i must say i tend to do this the easy way....

rm Alv<tab>

this fulls out the filename including with all the required backslash escapes needed
 
Old 05-26-2010, 01:40 AM   #23
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,550

Rep: Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898
@dasy2k1 - and after you have done this 50 or so times it could get laborious especially if you have several different files all starting with Alv
 
Old 05-26-2010, 03:59 AM   #24
NickJH
LQ Newbie
 
Registered: Mar 2009
Distribution: ClarkConnect CE5.0
Posts: 19

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by dasy2k1 View Post
i must say i tend to do this the easy way....

rm Alv<tab>

this fulls out the filename including with all the required backslash escapes needed
You'd do that every hour 24/7? Good on you. I prefer cron scripts (if I can work out how to write them)!
 
Old 05-26-2010, 09:55 AM   #25
dasy2k1
Member
 
Registered: Oct 2005
Location: 127.0.0.1
Distribution: Ubuntu 12.04 X86_64
Posts: 960

Rep: Reputation: 35
@NickJH diddnt realise this was a multi delete with regularity thread....

if that was the case i would most likly use some sort of regex based script that was run by cron
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Script help - delete files older than 45 days but exclude the system files jojothedogboy Linux - Software 3 06-13-2008 04:43 PM
Delete old files script simpi Linux - Newbie 11 04-25-2008 03:37 AM
How to write a script to delete files? AGazzaz Linux - General 11 12-05-2007 07:43 AM
script to insert filenames into files magnim Linux - General 4 03-22-2007 02:05 PM
Shell script: Delete filenames containing a substring? Drack Linux - General 4 02-12-2006 04:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:54 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration