Linux - NewbieThis 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
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.
Now there are some issues surrounding Length and your criteria. As a[3] and a[4] are the portions of the time / length element, you could have values of a[3] = 1 and a[4] = 00.
Based on the criteria, in total 1:00 is greater than 0, however the logic here wants them both to be not 0. So I changed that part to be an OR
Other changes are cosmetic at some level but may also help speed up process:
1. By using 'sve' in line 2 as part of the test it will only start looking for values should the previous line contain 'slsk'
2. I removed the superfluous '.*' from the start and the end ... no real value added
3. By adding match out the front we remove the need to assign to variable 'good'. The return value is greater than 0 only if it finds a match
4. I wasn't sure with your new grep as to which part of the original line you needed. If you could demonstrate we could us a simple substr / gensub to get the data required
5. 'sve' is reset to blank so as to not start match if not needed
I tend to not reset saved portions to acccommodate possible multiple following entries per "saved" - seems the (more) common case. As for "good", that's just habit ...
Now there are some issues surrounding Length and your criteria. As a[3] and a[4] are the portions of the time / length element, you could have values of a[3] = 1 and a[4] = 00.
Based on the criteria, in total 1:00 is greater than 0, however the logic here wants them both to be not 0. So I changed that part to be an OR
Other changes are cosmetic at some level but may also help speed up process:
1. By using 'sve' in line 2 as part of the test it will only start looking for values should the previous line contain 'slsk'
2. I removed the superfluous '.*' from the start and the end ... no real value added
3. By adding match out the front we remove the need to assign to variable 'good'. The return value is greater than 0 only if it finds a match
4. I wasn't sure with your new grep as to which part of the original line you needed. If you could demonstrate we could us a simple substr / gensub to get the data required
5. 'sve' is reset to blank so as to not start match if not needed
thanks for the solution!
Last edited by Scottish_Jason; 11-26-2014 at 06:26 PM.
Guys thanks for the suggestions, a lot of it is over my head as I am quite new to this all.
What do you mean by example data instead of solution data?
the data supplied is what I get when piping the output of an application (to results.txt) that does a search and supplies the data as shown.
Hi Jason, I was referring to the examples you had provided and the fact that they all match out criteria. So we have no examples
that should be excluded by our code. So currently we are testing only for success and not seeing ones that might be close to matching but little
things should actually be dealt with.
If the solution is working though ... good work
Once you think you have a working solution, remember to mark your question as SOLVED.
Hi Jason, I was referring to the examples you had provided and the fact that they all match out criteria. So we have no examples
that should be excluded by our code. So currently we are testing only for success and not seeing ones that might be close to matching but little
things should actually be dealt with.
If the solution is working though ... good work
Once you think you have a working solution, remember to mark your question as SOLVED.
Actually yes, it appears to be working well, I just need to somehow cut the number from the output so I'm only left with a result starting from "slsk" and not [67] slsk://blabla.mp3
any suggestions? This is what I currently have...... thanks to you guys
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.