Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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:
(you can ignore the two 'sep'statements - they just print a row of dashes, to make script output easier to read, and is used in other scripts)
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?
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.
You can negate a test using !. If you want to exclude the .org, .co.uk, .com, and cache- files, you can do something like:
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.
where your version doesn't get the ones that don't have the .org at the end of the term. Both are OK though (note that this isn't a criticism in any way; I didn't give any kind of spec for what it should do and I hadn't thought about this part.)
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:
Regarding your second question I think you can't avoid to use positional parameters.
Ah well, I was hoping that there was a clever and simple way that I was overlooking, particularly as it is such a common problem.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.