ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
What's the most efficient way to go about this? I am not so bad with bash untill I have to batch process bunch of files like this. I know tiny little bit of awk and sed. Should I use them? Would it be an overkill if I do? Would expr utility be helpfull here? Please help.
Last edited by frankie_DJ; 10-04-2006 at 04:57 PM.
What's the most efficient way to go about this? I am not so bad with bash untill I have to batch process bunch of files like this. I know tiny little bit of awk and sed. Should I use them? Would it be an overkill if I do? Would expr utility be helpfull here? Please help.
OK thank you guys. Wow. I can't believe I lost all afternoon on this thing.
SOrry ghostdog, but I don't have time to deal with yet another language. Although from what you wrote python seems really powerfull.
Jonaskoelker, thanks for the script. It didn't work out of the box, since shell doesn't do arithmetics with real numbers, so I had to pipe to bc. Also the second use of IFS (IFS=',') doesn't really do what it's supposed to and I don't really know how to fix that.
Edit: Pete, thanks, I will see if your script works better. By the way, isn't it overkill to use awk and sed? I mean sed loads about 50K of memory and awk probably even more. Just curious.
Last edited by frankie_DJ; 10-04-2006 at 08:45 PM.
Distribution: Slack, FreeBSD,NetBSD, OpenBSD, Open Solaris, Minix
Posts: 172
Rep:
Quote:
Edit: Pete, thanks, I will see if your script works better. By the way, isn't it overkill to use awk and sed? I mean sed loads about 50K of memory and awk probably even more. Just curious.
You're welcome, and you're probably right. I'm sure you could do it with sed or awk alone. I wasn't really thinking about conserving. system resources.
Thanks guys, I spend half a day on this but it wasn't wasted - I learned tons. If someone sees this and has few minutes, I wouldn't mind a version with awk only.
Also, I was curious why switching IFS doesn't work in the first version.
Here's the beginning of an awk version, untested because there was no live data posted that I saw. You may need to adjust the variables, and, of course, remove the "next" statement ... cheers, makyo
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.