print values from stress to an array-syntax error {
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.
I think it might be tidier to print them out in arrays but when I do, I always get a syntax error of { missing even when there isn't. How can I convert this to print the values of column $13,$14$15 through using arrays rather than the way above?
The output of both should be the same but I feel the arrays look tidier in terms of output.
Last edited by rmcateer; 03-01-2015 at 12:42 PM.
Reason: add code tags
Unless you first place those 3 values in an array you will not be able to print it out as an array as there is no built in array variable containing the information.
So your current method or pan64's are the most straight forward ways.
what about for outputting sar -d 1 10? I am trying to stress the disk and output those results in a command, which I will then graph in excel. But when I use [code]awk |'NR > 1 {printf "4s%8s%8s\n",$13,$14,$15}'[/code} and
Well I know nothing of sar command, but would suggest if you want to pretty up the output you will need to play with the formatting.
awk is currently giving you exactly what you told it to, ie 13, 14 and 15th fields separated by a tab for all lines greater than 1.
I would suggest you look at the printf command and the multitude of options or perhaps try a stronger tool like Perl or Ruby to manipulate the data.
I have tried but it is still giving me bother when I try other sar commands. Are there any disk related commands(I am stressing the hard disk drive) that run in a manner similar to vmstat, iostat and sar, i.e. one that can be typed and then run for a certain number of intervals and fr a certain time?
You might need to show a before and after picture as I do not have the data to see what your issue is. Why can you not format the data using printf or the like?
I would add that it will not probably be a quick solution, you will need to try a few iterations to get it right.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.