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.
Which is the desired output. On the others the output gets all messed up. Can anybody see by looking at the output of df on debian squeeze what might be happening?
I'm sure it's just a difference in df and awk between the systems.
This is squeeze:
Code:
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 6.0.7 (squeeze)
Release: 6.0.7
Codename: squeeze
Code:
GNU Awk 3.1.7
This is wheezy:
Code:
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 7.3 (wheezy)
Release: 7.3
Codename: wheezy
Code:
mawk 1.3.3 Nov 1996, Copyright (C) Michael D. Brennan
compiled limits:
max NF 32767
sprintf buffer 2040
Last edited by master-of-puppets; 09-30-2014 at 09:28 PM.
I doubt you'll find many people who want to dig through all that code. Have you looked at the actual output from df on each system? One problem might be that df can insert extra line breaks when mount point names get too long. You can use the "-P" (--portability) option to prevent that.
My other suggestion is to try the standard debugging technique of putting a "set -x" command at the top of the script and then examining the output in detail to see what is actually getting executed. Saving the output from df in a file rather than piping it directly to awk might also prove instructive.
I agree that it is a lot of code and rather vague description of what you need, and you expect someone to respond in 3 hours.
It shouldn't be too difficult for you to debug it, but nearly impossible for us with the amount of info you gave. Look at the output of 'df' on each system and you are likely to figure it out, if not, post the output. Also, adding functions will help clarify what is going on.
I doubt you'll find many people who want to dig through all that code. Have you looked at the actual output from df on each system? One problem might be that df can insert extra line breaks when mount point names get too long. You can use the "-P" (--portability) option to prevent that.
My other suggestion is to try the standard debugging technique of putting a "set -x" command at the top of the script and then examining the output in detail to see what is actually getting executed. Saving the output from df in a file rather than piping it directly to awk might also prove instructive.
I'll add the output of df at the top of my post and I will use pseudo code to show to what's supposed to be happening. I have been pulling my hair out all day trying to figure it out. Please stay with me.
I agree that it is a lot of code and rather vague description of what you need, and you expect someone to respond in 3 hours.
It shouldn't be too difficult for you to debug it, but nearly impossible for us with the amount of info you gave. Look at the output of 'df' on each system and you are likely to figure it out, if not, post the output. Also, adding functions will help clarify what is going on.
I'll add the output of df at the top of my post and I will use pseudo code to show to what's supposed to be happening. I have been pulling my hair out all day trying to figure it out. Please stay with me.
awk -v A="$(date +%m-%d-%y)" ' BEGIN { printf A } '
looks better at least for me.
About looking for valid lines you can do the following too:
df -m | awk '/% \// { printf ",%s,%s", $2, $3; }'
gawk provides the following functions for working with timestamps. They are gawk extensions; they are not specified in the POSIX standard. However, recent versions of mawk (see Other Versions) also support these functions.
awk -v A="$(date +%m-%d-%y)" ' BEGIN { printf A } '
looks better at least for me.
About looking for valid lines you can do the following too:
df -m | awk '/% \// { printf ",%s,%s", $2, $3; }'
I'll try it when I get some time thanks. Plus I'm taking an awk tutorial to save you guys headaches.
---------- Post added 10-01-14 at 03:23 PM ----------
Quote:
Originally Posted by grail
Is there something wrong with awk's date abilities?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.