Ubuntu :: Calculate An Average In A Simple Way With Bash?
Mar 3, 2010
does anyone know how to calculate an average in a simple way with bash? I've got something like this:
Code:
$ cat results.txt | head -10 | tr " " " " | cut -f13
0.23929285124
0.404716908011
0.35113102608
[Code]....
and now I want to calculate the average of the resulting numbers. I know I could write a bash or awk or perl script and use that, but isn't there a more simple, elegant way? There is for example "sum" in the coreutils, but no "avg"..
View 9 Replies
ADVERTISEMENT
Nov 15, 2010
I would like to subtract the end time with a start time in bash. How can I do it?
Here's a script of example of what I want:
View 8 Replies
View Related
Jan 28, 2010
i have a sorted file with many repeated lines like this:
1ujw
1ujw
1ul1
1us7
[code].....
i need to calculated haw many times each line is repeated, for ex
1ujw 2
1ul1 1
1us7 5
etc.
View 5 Replies
View Related
Dec 12, 2008
I want to calculate log in bash script. I searched but could not find any bash command to directly do it. I am also thinking to send the variable in C program, calculate in C and get the answer back in bash script.But I think it is a long process. as I have to do this
i) gcc -o log log.c
ii) ./log > log_result.txt
iii) then read the result from log_result.txt
View 5 Replies
View Related
May 26, 2010
For reasons I won't get into, I need to copy directories so long as the average system load is low. Can someone help me write a BASH script that will copy the contents of a directory, but check to make sure the average system load is below X before copying each file, and if not, wait Y seconds and try again?
View 3 Replies
View Related
Oct 26, 2010
I am trying to use the date command in a simple bash script as below:
#!/bin/sh
this_date=`date`
echo "The date is $this_date"
This script seems to work only if a surround the command with the `` characters, which I copied from another script. Can anyone tell me why this is, and how I can insert these characters from my keyboard,which only has normal quote and double-quote characters?
View 5 Replies
View Related
Nov 7, 2010
I have been looking at: ut a lot of it is to do with files and numerical comparisonswhat would be the bash equivalent of:if (http isin $2) { do something }
View 2 Replies
View Related
Nov 4, 2009
I am trying to create a function that takes a pair of a high and a low limit, and returns an arbitrary number between them. Below is my attempt to create a function that accomplishes this by checking to see if they are equal, and if not, subtracts a very small number from the high limit and returns the result.
View 2 Replies
View Related
Feb 18, 2010
When I run this command from shell, it runs ok
export REVS=`svn info svn+ssh://svn.myone.ca/var/svn/story/trunk/lib |grep 'Last Changed Rev:'| awk -F: '{print $2}'`
However when I save it into a file called test.sh (of course, I chmod it with +x), I got error "export: 2: bad variable name"
Here is the file:
#!/bin/bash
export REVS=`svn info svn+ssh://svn.myone.ca/var/svn/story/trunk/lib |grep 'Last Changed Rev:'| awk -F: '{print $2}'`
I am using ubuntu.
View 7 Replies
View Related
Feb 20, 2010
Are there any tools that can be used to create a simple GUI for the bash script files i have created, and the GUI should be able to run on both Solaris and Red Hat systems.
View 4 Replies
View Related
Jul 9, 2011
I wrote this script which works but it should run automatically about once per week. I hunted and experimented with KDE Task Scheduler (no dice and no help anywhere) and cron (confusing instructions and cannot edit crontab -e with vim, and cannot enter cron folders/files). I would settle for a desktop shortcut to run the script but found no for that.
Script:
Code:
#!/bin/bash
xterm -hold -e fstrim -v /
Machine:
OS: openSUSE 11.4 x86_64
[code].....
View 13 Replies
View Related
Dec 24, 2010
All of a sudden,i can't execute a simple script as follows:
exit 0
and:
exit
View 18 Replies
View Related
Jun 14, 2010
I am running a simple script that I copied from slug.ceca.utc.edu/docs/2009-3-26-linux-server-health.pdf and edited with the names and paths of my own servers. I don't know much about scripting (re: nothing) but I wanted to try and be efficient in my new role as a Linux Sys Admin. The script was saved to root's home directory and runs as part of root's crontab once a week. The script runs with no problem, but it doesn't actually seem to run all of the commands contained within. It skips some in the middle and the end and I don't know why. The script itself is this:
Code:
#!/in/bash
uname -a > /tmp/server.txt
[code]...
View 5 Replies
View Related
Sep 14, 2010
I have a very simple bash script:echo -n Create home directory?:
read HOMEDIR
if [ $homedir="y" ] || [ $homedir="yes" ]; then
homeval=" --makehomedir"
[code]...
View 6 Replies
View Related
Apr 3, 2011
How to made a simple website in linux using bash scripting.
View 3 Replies
View Related
Jan 31, 2011
I have a folder of 2 many files that the old ls just hangs.
I am trying to write some log files such as;
I don't mind doing one at a time, but I am just playing and even getting the listing I am not getting the date stamp, I have the following;
That does create the file, but all the files look like this;
So basically it's just sticking that ls inside the log file and not actually running the ls, so how can I use the above type to get files just created per year?
View 2 Replies
View Related
Aug 2, 2009
Ive been using linux for a while but I am just getting into shell scripting, im currently trying to get a simple script for finding and copying files powered by the command:
Code:
This works fine from the command line but when put in a script such as:
Code:
Code:
with the keyboard inputs for $fc1 and $fc2 being *.doc and ~/test respectivly. The only problem i can see is the xargs -ivar "var" part possibly needing $var to be defined?
View 2 Replies
View Related
Oct 7, 2010
i'm a college student studying pc programing, and i was given today a special work and i have to program using miranda... which i've never used it >.< can anyone give me a hand to where to download, how to compile, and a simple tutorial for making a simple program or something?
View 3 Replies
View Related
May 18, 2011
I am a long supporter of Ubuntu and faithfully been updating every release from 8.04 till 10.10 ...I use an old Laptop with 512 MB RAM.I was not able to run the default Unity and I was dropped to GNOME .. This is the first time I am seeing a difference in Ubuntu trying to cater only to the more modern computers,.. Is the original spec of 384 MB RAM in previous versions no longer hold good?
I have an NVIDIA Card but I guess that is not enough..Any idea what is the problem in my config:Dell Inspiron Centrino Proc (1.4Ghz) , 512 MB DDR 1 , Nvidia.
View 7 Replies
View Related
May 5, 2010
Since upgrading from 9.10 to 10.04, my system is noticeably less responsive and exhibits halting behavior for at times 10s of seconds. There is nothing obvious in the various logs that I can find. The only objective indication I can find that demonstrates that something is seriously wrong is that my load average never drops below 0.5 and is often over 1.5, even at idle. In this situation, top/ps/whatever shows very few processes running (usually just top). This suggests to me that either the new kernel scheduler is horrible or that something new is resulting in blocking I/O or other uninterruptable sleeps.Typical top output:
Quote:
top - 12:18:01 up 1 day, 49 min, 5 users, load average: 1.42, 0.86, 0.71
Tasks: 262 total, 1 running, 261 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.9%us, 0.8%sy, 0.0%ni, 97.6%id, 0.0%wa, 0.0%hi, 0.7%si, 0.0%st
[code]....
View 9 Replies
View Related
May 29, 2010
I can't upgrade. I get:
Quote:
Could not calculate the upgrade
An unresolvable problem occurred while calculating the upgrade: The package 'skype-common' is marked for removal but it is in the removal blacklist.
This can be caused by:
* Upgrading to a pre-release version of Ubuntu
* Running the current pre-release version of Ubuntu
* Unofficial software packages not provided by Ubuntu
This is most likely a transient problem, please try again later.
I tried again several times in different days and it is the same. I have 10.4 recently updated from my original installation of 9.10. I think it was not a pre-release, I did it automatically from the website and it took a long time. As far as I know, all I have installed is official, except perhaps Skype itself. There seems to be something connected with Skype. But I have exactly the same Skype I had with 9.10, where I updated every few days with no trouble. It is something peculiar in 10.4
View 7 Replies
View Related
Jun 15, 2009
I read the man pages of batch and it says that commands or scripts scheduled using the batch command will only execute when the load average goes below 0.8. As a newbie I hardy understand what it means. Does it mean that the system resources are busy?Ans since I want to see the o/p of the commands I have set using batch, is there any way i can bring the sys load average below 0.8?
View 3 Replies
View Related
May 1, 2010
Upgraded from 9.10 to 10.04 Thursday night. My internet was working perfectly under 9.10, but when I turn my comp on friday morning, my internet speed has been crippled to almost a halt.
In short, I get about 25 kb/s average speed, when it doesn't completely drop me. Under 9.10, I had 250+ kb/s. Why is this? I figure it has to be a bug, but is there any way to fix it? It's rendering my ubuntu install completely useless. I'm lucky I got my windows partition fixed, or else my laptop would be more or less a paperweight for a while. This is on the same laptop by the way, same internet connection.
View 8 Replies
View Related
May 7, 2010
A server of mine previously running ubuntu 9.10 used to be between 0.01 and 0.10 load average during the normal load of users using various server programs on it (mostly apache with php scripts).
Now, after upgrading to 10.04 (which went smoothly for the most part), the load average is much greater under the same user workload, hovering between 0.1 and 0.3 under very light work and up to and over 1 regularly when more users are accessing the same scripts.
Are there any known issues that would cause greater usage of the same resources in lucid, or are there any ways I can trace what's causing the higher load? Downgrading or starting with a fresh install are last resorts, as there are a lot of customized options specifically set up for this server and I'd rather not go through backing them all up and restoring them after a complete wipe.
View 5 Replies
View Related
Oct 15, 2010
It's the fourth time now since Maverick that I had to cold reboot my system because it was totally unresponsive. The system monitor in my taskbar shows 100% on the background blue graph (I guess that's just one core then) and almost nothing on the other core. On the last freeze I managed to open 'sudo top' before it went totally unresponsive and saw that there was no high CPU usage at all, but a load average spiking above 24. Also the swap seemed to be full although my machine usually never uses swap. I was watching a movie with VLC this time, but I'm not sure if VLC ran the other times my OS froze. I made a snapshot with my cell phone: [URL]. How I can prevent a process from causing so much load?
View 6 Replies
View Related
Nov 26, 2010
I am having a problem with the server that I use to host my personal site. The load average quite often spikes to exceed 1.00 for the 1 and 5 minute intervals, and the 15 minute interval gets above .5. This occurs while the server is idle, serving very few or no requests and with the CPU 99% idle with <1% IOWAIT usage. I have checked top and vmstat, but neither one provides any useful info. Top continues to say the CPU is 99% idle, and vmstat says that there are 0 runnable and 0 blocking tasks. Occasionally, vmstat will say that there is 1 runnable task, but this doesn't even coincide with the load average spikes. I have already searched for other solutions to this problem, but everything I have seen says to use top and/or vmstat, but those aren't showing anything out of the ordinary. Can anyone recommend anything else I might do?
My server has a Pentium 4 HT 3gHz processor, 2GB RAM, and runs Kubuntu 10.10. (The reason it runs Kubuntu instead of Ubuntu Server is that it needs an X environment so that the Nvidia driver can initialize and put its graphics card into a power saving mode.)
View 8 Replies
View Related
May 3, 2010
I tried to upgrade Ubuntu Server Edition 9.10 to 10.04. Gives me this warning:
Code:
Could not calculate the upgrade An unresolvable problem occurred while calculating the upgrade: E:Unable to correct problems, you have held broken packages.However, the packages appear to be fine. Checked with apt-get and nothing wrong.
View 9 Replies
View Related
Jul 19, 2010
i have problem with upgrade manager. i try upgrade fron 8.04 to 8.10. where is my main.log:
2010-07-19 15:52:51,749 INFO release-upgrader version '0.93.34' started
2010-07-19 15:52:51,752 DEBUG Using 'DistUpgradeViewText' view
2010-07-19 15:52:51,795 DEBUG enable dpkg --force-overwrite
[code]....
View 1 Replies
View Related
May 30, 2011
I received the following error today and I did a search on the net. I tried sudo rm /var/cache/apt/archives/* but it didn't help. Could not calculate the upgrade An unresolvable problem occurred while calculating the upgrade. report this bug against the 'update-manager' package and include the following error message: 'E:Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.'
View 9 Replies
View Related
Jul 12, 2011
I was struggling to find the information so I thought it would be easier to ask here. What does the load average as reported by top mean ? To me those are 3 mysterious values, which most likely refer to some average CPU usage and this is all I know about it (not sure if it's true).What is the maximum value for this parameter (I guess the minimum is 0.00) and what does it mean ?
View 5 Replies
View Related