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.
I currently have a script that checks whether some cameras have been recording continuously since a given date. If it finds times where the recording stopped it echos the path and how much time was stored there. This all works fine so I don't need any help there.
Now I want to create a script that takes everything printed by the last script and organizes it into a nice table. Would awk be the best thing to use for this?
I can still manipulate what the output of the other script is so I figure I should be able to put some sort of separator in (";" maybe). The table will have to show a few different types of errors (not enough time, camera reset, etc.) along with the path so I might need different types of separators for different things? This is my first time writing a script of this nature so I'm just throwing some ideas out there.
If anyone could give me some insight as to how to get started that would make this much easier. I don't want to sink a few hours into this just to find out I could have used a much easier method.
awk is a good tool for a single table of data. You can set the field separator and it will automatically split the fields for you so you can modify and print the output formatted the way you want. You can also print the table header in the BEGIN block and a summary in the END block (for example).
If you need multiple levels of fields I would use Perl which has a general split command that can split a string on any pattern. If you don't want to spend the time learning Perl you could still do this with multiple calls to awk. But it might be a little more "awkward".
Awk should be fine - I learned perl well before awk, but now use the latter almost exclusively for "quick and dirty" reports from logs.
match() should do similar in a single call (per input record).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.