Simple bash scripting question, involving finding newer files
This is a simple syntax question about trying to find files that are newer than a certain date within a particular directory tree (in this case,within a .kde4 tree). This is just out of general interest, and can't be said to be in any way urgent, as I'm just trying to satisfy curiosity here and my crude script accomplished the necessary minimum.
What I am trying to do is use find to go through the .kde4 tree and find what is new there. What I've got is: Code:
sep The first issue is that the line of 'grep -v' statements is inelegant, and I'm sure there is a way of filtering several things at once, but I can't figure out the syntax. The supplementary question is that the script uses fixed parameters (-mtime 5, .kde4) which it might be nice to read from the invocation. I could read $1, $2,... but sorting out the business of the parameters being given in different orders, sometimes being present, sometimes absent, sometimes non-numerical parameters being given where numbers should have been given and this seems more complication than is sensible for a trivial script. Is this because I'm trying to do this the hard way, and there is an easy way that I should be using? |
Quote:
Code:
find ~/.kde4 -type f -mtime -5 ! -name \*.org ! -name \*.co.uk ! -name \*.com ! -name cache-\* -ls Regarding your second question I think you can't avoid to use positional parameters. A bunch of checks at the beginning of the script it's easy to implement. Every time some condition is not satisfied, you can print a "usage" message and exit. "usage" can be a function at the beginning of the script, so that you have not to repeat the same lines of code all over the script. |
Yes, that's neater than my version. Oddly though, it doesn't quite work as well for me in a way that I hadn't thought of.
It turns out that my version also cuts out some stuff like Code:
.kde4/cache-lenny/http/d/download.kde.org_khotnewstuff_plasmathemes_previews_m100945-1.png_7369118b_freq I probably should have given some more detail, although you have figured out the important parts; I was trying to have a look at a user's kde tree, to see what had been changed, if anything, in an update. Just looking at everything that has been changed since the update doesn't give a clear picture because it throws up lots of stuff that has been changed, but isn't relevant, such as cached records of websites, apparently. hence the isea of scrubbing the .com, .org and .co.uk, which gets a lot of the junk in my case. Quote:
Anyway, thank you for your help. |
All times are GMT -5. The time now is 01:50 AM. |