I have a problem with arithmetic ops in awk.
Here is what my script does right now.
I have a file named frames.txt with two columns (nr and val)
Additionally I have a file input.txt:
awk searches for the pattern "eigenvectors" and use the last field (which is a positive value usually) of input.txt and substract the corresponding value of frames.txt. In this case, 6.6 - 1.2 = 5.4
But sometimes $val and $NF are negative values ($NF= -6.6, $val=-1.2). This would mean that the arithmetic operation is: -6.6 - (-1.2) = -6.6 + 1.2 = -5.4 --> This would be the equation I'm aiming for, but instead I get as output:
-6.61.2
So something must be wrong with my operation. There is no substraction, the numbers are just strung together with the minus of 1.2 missing.
Could you help me to fix this problem please?
Thanks in advance
Last edited by tobias1234; 05-22-2012 at 05:43 AM..
Reason: Please use code tags
Hello Folks,
I have a variable output holding date as below -
output = "20141220"
I need to extract a day out of it and store it in another variable i.e. something similar to below -
output1=20141219"
and if the month is changing i.e. date in on 31st or 1st it should be taken care of
"date... (5 Replies)
Hello,
date --date '-60 min ago' +'%Y-%m-%d %H:%M:%S,%3N'
Above command gives the date and time minus 60 minutes
but the problem i am facing is, i do not want to hardcode the value 60
it is stored in a variable var=60
now if i run below command , i get error
date --date '-$var min... (3 Replies)
Hi the below code is failing i am trying to generate do the following:
2014-10-22 11:26:00 (Substract 24 hrs)
should produce
2014-10-21 11:26:00
I need the same formatting below because that gets inputted into code for an... (4 Replies)
Hi,
I need to subtract 5 minutes from the date. Example
$date +"%Y-%m-%d-%H.%M.%S" displays 2014-06-26-06.06.38
I want to show it as 2014-06-26-06.01.38 (5 mins are subtracted from date)
Any help would be appreciated. I am currently on AIX version 6.1
-Vrushank (10 Replies)
hey, i have a list of devices that looks like so:
VolumeTask(DeviceName(DeviceName(DeviceNameInfo(MultiPathType_UID(Option<GUDeviceID>(GUDeviceID(ulonglong(358271365120608989UL))),Option<ulong>())))),2098560),... (5 Replies)
I need to rename a directory full of files named like:
page_001.jpg
page_002.jpg
page_003.jpg
to the file name minus one. Meaning instead of page_001.jpg that file becomes page_000.jpg so:
page_001.jpg => page_000.jpg
page_002.jpg => page_001.jpg
page_003.jpg => page_002.jpg
I was... (3 Replies)
Hello people,
awk '{print $0}' input1.txt input2.txt |sort -u
Will give the union of the 2 files. Similarly what is command to get just the diff data (i.e minus) of the 2 files. Can I use the "diff" command to get just the diff data.
Please let me know.
Regards,
Tipsy. (7 Replies)
my file looks like this:
101928 101943
101928 101944
101929 101943
101929 101943
101929 102044
i want to insert bc to get answer like this:
101928 101943 000015
101928 101944 000016
101929 101943 000013
101929 101943 000014
101929 102044 000115
total 000173
my... (3 Replies)