LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 03-19-2020, 11:25 AM   #16
drgibbon
Senior Member
 
Registered: Nov 2014
Distribution: Slackware64 15.0
Posts: 1,224

Rep: Reputation: 946Reputation: 946Reputation: 946Reputation: 946Reputation: 946Reputation: 946Reputation: 946Reputation: 946

Quote:
Originally Posted by pan64 View Post
again, find has a -delete, no need to -exec rm
Fixed that, thanks.

Quote:
Originally Posted by pan64 View Post
I don't really know how many files will be deleted and how long does it take (to find all), but in some cases executing that find two times looks not really efficient. Need to save the result of the first run (if speed is important) - and remove the collected files after the "Really delete" prompt.
That was my original idea, but I'm not certain on how to properly store the results from find and then safely delete them all (accounting for weird filename characters, etc).

*edit* I had looked at this, and it looks a bit wild to me.

Last edited by drgibbon; 03-19-2020 at 11:28 AM.
 
Old 03-19-2020, 11:57 AM   #17
drgibbon
Senior Member
 
Registered: Nov 2014
Distribution: Slackware64 15.0
Posts: 1,224

Rep: Reputation: 946Reputation: 946Reputation: 946Reputation: 946Reputation: 946Reputation: 946Reputation: 946Reputation: 946
So maybe if you want to avoid the double find call, this is a safe way:
Code:
readarray -d '' files < <(find $DIR -type f -maxdepth 1 -name "*.avi" -size -6M -print0)
printf '%s\n' "${files[@]}"

read -p "Really delete all? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
  rm -i "${files[@]}"
fi
This is specific to bash (>= 4.4), so -current only. Seems to work with strange characters in filenames, I'd test this though, hence the "rm -i" bit. Other people might know better ways though, I'm just looking at this for fun
 
Old 03-19-2020, 01:08 PM   #18
FTIO
Member
 
Registered: Mar 2015
Location: Las Vegas, NV
Distribution: Slackware 15.0 x64, Slackware Live 15.0 x64
Posts: 621

Original Poster
Rep: Reputation: 363Reputation: 363Reputation: 363Reputation: 363
Thanks everyone, for all the suggestions.

Usually when I wake up and maybe once or twice throughout the day I'll go into the directory that has all the videos that caught 'motion' and look at them.

The videos that are 4MB and smaller usually will be a car going by relatively quickly (figure 5-10 mph, no faster as this is a trailer park and the main road runs right down the middle of us all, heh).

Other things like a cat or bird or bug, or a kid or two running to the bus stop, all usually are pretty quick and make a file of 4MB or smaller.

Anything larger I want to watch in MPlayer or whatever to make sure it isn't something that happened I want to know about or at least have the video to use as 'proof', etc.

So I've gone ahead and forgone the need to check anything 4MB and smaller and just use the first good script we came up with in this thread. If I let things go without checking for, let's say, 6 hours, there will be around 20-30 files and probably 10%-20% will be those I can delete without worry of looking at them. It takes time to watch what's leftover, if you figure a 9MB file lasts approximately 20 or 30 seconds and I have 20 to look through, heh.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
PTY allocation request failed on channel 0 shell request failed on channel 0 sandeep002gupta Linux - Server 3 06-12-2019 07:17 AM
Real quick iptables question (I mean real quick) sir-lancealot Linux - Networking 1 08-25-2010 08:41 PM
LXer: A Quick Look at Qt Quick LXer Syndicated Linux News 0 06-09-2010 05:00 PM
Bad Request Your browser sent a request that this server could not understand. vishnukumar Linux - Server 2 08-13-2009 12:56 AM
webserver doesn't reply to external request but it reply's to local request ziba Linux - Server 4 05-11-2009 05:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 01:22 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
Open Source Consulting | Domain Registration