General :: Arithmetic Operation In Bash?
Mar 10, 2011I've the following input file (sorted.txt)
Code:
A 1
A 1
[code]...
I've the following input file (sorted.txt)
Code:
A 1
A 1
[code]...
I wonder how to arithmetic operation of our data file using any script program/command (like sed, cut,awk)for example my data.file is:
45 65 42
12 23 61
43 34 21
I want to multiply first column with 2 and add second column with 3 then it become
90 68 42
24 26 61
86 37 21
I have four files that contain numbers that I grep for in a variable#!/bin/bashcat FILENAME`date +%y%m%d*.tot` | grep Grand | awk '{print $4}'
#output is
12
67
[code]...
I do not understand bash' syntax regarding the use of ((<arithmetic expression>)). $((<arithmetic expression>)) is tokenised to a single word. OK.
Code:
In isolation
Code:
It may not be used where a word is expected. This generates a syntax error. Why?
Code:
My main problem right now is doing floating point arithmetic within a bash script, with variables.Right now I have a folder called "myExamples" with a script called "run_example" that runs with no issues.I plan to(1) create many folders inside [myExamples], that are named [example10] [example11]...each containing an identical copy of (run_example),(2) modify Line 172 of each copy of (run_example)...in one copy, it would be 3.00, the next copy would have 3.05, etc. (This part doesn't work!)How can use the available calculator bc code to do floating point operations?My code is below -
#!/bin/sh
# run from directory where this script is
cd `echo $0 | sed 's/(.*)/.*/1/'` # extract pathname
[code]...
Fedora 12 gcc 4.4.1 I am doing some programming, and my program gave me a stack dump. However, there is no core file for me to examine.
So I did:
Code:
ulimit -c unlimited
and got this error message:
Code:
bash: ulimit: core file size: cannot modify limit: Operation not permitted I also tried setting ulimit to 50000 and still got the same error. The results of ulimit -a:
Code:
$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
[Code]...
my host is x86_64 and run hosted redhat server5.4 X86_64, i complies my code with -m32 option open, my code run smoothly in my host, but when it installed on redhat9.0 host(x86_32) the error occurs and the output is :"Program terminated with signal SIGFPE, Arithmetic exception" but thought whole my code, there no divide operators,i write the "hello world" program, the same problem also occurs
View 1 Replies View Relatedi write this script:
[Code].....
i make this script to become a service ( i test it from bash, and my script work good), my problem is when i telnet to my local host (127.0.0.1) via a personal port like 5555 telnet give this error: ")syntax error: invalid arithmetic operator (error token is ", i know this error is for echo $(($A+$B)) and i know that telnet can not calculate $A+$B and the error is for this
GNU Emacs 23.1.1 I've noticed that if I run Emacs and M-x server-start, I can use the emacsclient program as usual, but if if I start Emacs using emacs --daemon and then try to use emacsclient the new frame locks up and the shell outputs *ERROR*: Arithmetic error. This issue doesn't happen if I use the -t flag to force terminal mode when running emacsclient.
View 2 Replies View RelatedIs it possible to do arithmetic in shell scripts? If so, just how is it done?Here is the code so far:
Code:
#!/bin/bash
time=$(date +%H%M)
[code]...
What is the difference between *ptr++ and (*ptr)++. In my opinion the terminology is all over the place so if you could give an example it would be better.
View 8 Replies View RelatedI'm trying to make a bash script that takes away two decimal numbers. This is to work out partitioning information.
Code:
hddsize=`sudo parted -s /dev/sda unit GB print | grep "Disk" | tr -d [A-Z][a-z] | tr -d '/: '`
trimsize="1.5"
partitionendsize=$(($hddsize - $trimsize))
I get an invalid arithmetic operator. Not sure how to minus these two numbers. Is it a floating point issue?
After I set to use some modules, say, pam_access.so, I want to know if there is a way for the administrator to check if any invalid attempt was happened and blocked by that module?
View 15 Replies View RelatedI was messing around with my drive trying some different arrangements of partition to get another one inside. overall the result doesn't differ much from the original but while messing with it I done a lot of steps. I thought GParted will do the minimal number of operations but it didn't. it just traced all my operations one by one. this gave it a few days worth of work. As I don't want to loose data I can't hit cancel but I don't want to wait few days for it. Is there any way to tell it to stop after completing the current operation? It's from natty ubuntu live cd.
View 1 Replies View RelatedI run SUSE on my machine for a year, but I'm really a newbie on Linux. In the system monitor it states:SUSE LINUX Release 11.2 Kernel Linux 2.6.31.5 -0.1 -desktop GNOME 2.28.0Last week when I rebooted my machine, I suddenly found my machine had no response to any click or typing. When the cursor move to any icons, they can be highlighted, but when I click them, no response at all. The weird thing is almost every time after I reboot the computer, it can work for a few minutes, then stop working. But if I press Ctrl+Alt+Backspace, it can be log out.
I think there must be something wrong with my GNOME, 'cause everything seems working fine when I login IceWM. recover the .config file in my home directory. But I don't have this file in my home directory.
I'm using fedora 11. I want to do some operation like after saving a file (moving ,copying,..) the system need to ask that "DO you want to encrypt?" . If yes I am able to run the crypt module (which I already implemented..). Is it possible to invoke a encrypt module which I implemented in c language.
View 2 Replies View RelatedWhat happen internally when we insert the floppy into the linux operating system? Who will take care of making the entry in the /etc/mtab, etc. Tell me whole internal operation of the kernel when we insert the floppy.
View 5 Replies View RelatedI am having a problem when I try to login as su.I type the command SU and then the password as normal and I get su: cannot set groups: Operation not permitted I am not sure what could of caused this error and how to fix it.
View 2 Replies View RelatedThe command and error message:
gtwy ~ # ip rule add from 64.251.23.186 table t1
RTNETLINK answers: Operation not supported
Older article of the same problem, but it did not help me: http://forums.gentoo.org/viewtopic-t-696982-start-0-postdays-0-postorder-asc-highlight-.html
I have looked on google at great lengths to try to find a solution. It seems that my kernel configuration is missing something? My system/kernel is: 2.6.36-gentoo-r5 #3 SMP Thu Jan 13 10:49:06 EST 2011 x86_64 Intel(R) Xeon(R) CPU X3220 @ 2.40GHz GenuineIntel GNU/Linux.I am posting this on SuperUser since this system is used as a workstation and this problem is unrelated to specific tasks that are handled exclusively by servers.iproute2 is installed:
gtwy etc # emerge --search iproute2
Searching...
[ Results for search key : iproute2 ]
[ Applications found : 1 ]
[code]...
I'm writing a script based on dialog and one of it's functions is to perform a restore with dd, of which I would like to show the progress by means of the "gauge" option of the "dialog" utility. I wanted to do this by sending a USR1 signal from time to time to the dd PID, because this results into the amount of bytes already being dd-ed ont the console screen. A simple calculation based on the orginal size would result into a percentage that can be fed to the gauge function of dialog.
The challenge I'm facing now is to launch an external script (I guess with "&" to send it to the background) that sends, let's say every 5 seconds a USR1 signal to the dd PID. That would be no problem, but how do I capture the output of this "kill -USR1" to the original script? I tested this and the output is not sent to standard ouput, so it must be that it is sent to standard error. For now I don't see a way out.
We often require to find an equivalent text command for any GUI operation. Just as an example we click on a folder (say ABC) from the current directory in order to see the contents of that directory. The equivalent command for it to happen would be->
Code:
cd ABC ls Now the thing is that we often don't know what that equivalent command will be. So I want to know that is there any way out to find it. What I want to do is that I shall perform any operation using mouse in the GUI mode(whatever operation it could be) and then I can see a log file to see what I actually did last(rather what the command would have been if I have worked in the text mode)...
When I first received it (used) a few weeks ago, this only happened occasionally and it took a while for a pattern to develop. The 7 hr stretch was listening to music of WCPE.org, but the next day I only could get minutes from the same site It sems to get progressively worse, yet the outside of the case, near the fan or anywhere else,doesln't get uncomfortably warm. I had another unit from the same vendor. He took that back and sent this one after a 24'hour test, but will not answer further communication. Generally I get best results if it has sat shut down overnight, but this morning even that was good for only a few minutes. It does this running XP from the hard disk or Linux from CD. Actually I would like to split the hard disk and put Linux on the second half as the default boot. But it won't run long enough to install anything now!
View 1 Replies View RelatedI installed pyxattr to play around with, and when I try to set them it says that the operation is not supported. Does Arch Linux not support xattr, or how do I enable them?
View 10 Replies View RelatedI had only Fedora 13 on my Dell Inspiron 1545. I found that there is a harddisk named volgroup in my computer & one another disk on which Linux is installed. The problem is that I can't access that space of my harddisk. It cannot be mounted.
View 1 Replies View RelatedI was observing the following behaviour:
py script:
os.mkdir(path) #all OK
operations_that_take_10hrs_to_complete()
os.mkdir(path) # permission denied
like I lost my sudo rights after some time ..
I am having an issue with HTTPS certification using curl. My curl is configured with OpenSSL. If the certification verification is failed I dont want to terminate the operation, instead I want to continue by just putting a log message. For this I have used OpenSSL SSL_CTX_set_verify() function to set my static C callback function. During HTTPS transaction, my callback is also getting called with first parameter 0 or 1 (depending upon of the certificate verification is success or failure). But even if my certification verification is failure, I want to continue. So I have hard coded to return value as 1 always from my callback function. But still I see the certification error and I don't get the page.
View 1 Replies View RelatedI`ve been given a project to design a program that will interface with a hardware device through the parallel port.And so far it`s not going go. I managed to write the programe an compiled it, but when runing it the compiler says: 'changing ownership of'and then the file name then it continues to say, 'operation not permitted'.
View 9 Replies View RelatedI tried to move 2.7TB of data from my /var/webroot/ partition (4.5TB total in size). I left it to run over night, this morning when I came to check I saw that all data on / paratition is used up and no operations can be done because of the "no space left on device" message.
Code:
Filesystem Size Used Avail Use% Mounted on
/dev/cciss/c0d0p7 911G 911G 0 100% /
tmpfs 7.9G 0 7.9G 0% /lib/init/rw
[code]....
I freed up several hundred MB from / but still the usage is at 100% and I cant free up any more space or complete the transfer ?
When I do a ntpq -p on my machine I could see the ntp servers configured and it's status:
But when I telnet to ntp server "10.1.35.2" it says A remote host refused an attempted connect operation:
I know * here represents that the machine is in sync with ntp server. My question if the machine is in sync with ntp server, how does it work?why ntp port 123 is connection refused?
I run a small site and today I've discovered that my site is down. I found that cPanel has flagged the account suspended even though I haven't got any quotas on the account. I don't know what went wrong. I've tried to unsuspend the account in WHM but a certain part of the function failed.
Quote:
safe_userchgid: chown: /home/crocbits/public_html: Operation not permitted at /scripts/cPScript/SafetyBits.pm line 93.
After searching the internet someone mentioned that the problem might lie in the permissions of the public_html folder. I had a look at the permissions and the folder had no permissions d----- When I try to chmod the folder I get this error:
Quote:
chmod: changing permissions of `public_html': Operation not permitted
I have no idea what to do next. All the files in the directory are locked too. I tried to move them but this command isn't allowed either. I ran these commands under the 'root' user in SSH.