Sponsored Content
Top Forums Shell Programming and Scripting Calculating an integer with awk Post 302587730 by sdf on Thursday 5th of January 2012 07:13:07 PM
Old 01-05-2012
Its probably not state of the art, at least I got the extraction of the number. Though could not resolve the integer calculation and thus print.

Code:
awk -v ss1="all_results" -v ss2="span" '{if ($0 ~ ss1) numb=index(substr($0,start=(index($0, ss1)+13), 10),ss2)-3} { numb=substr($0,start,numb); numb2=(numb / 25)}  {printf "%0f", numb2}'

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Calculating totals in AWK

Hello, With the following small script I list the size of documents belonging to a certain user by each time selecting the bytes-field of that file ($7). Now it fills the array with every file it finds so in the end the output of some users contains up to 200.000 numbers. So how can I calculate... (7 Replies)
Discussion started by: Hille
7 Replies

2. Shell Programming and Scripting

reading and calculating no. of occurrence in awk

:confused:Hi, I have got results from my simulation and I did extract the time field from the results file into new file. Then I was trying to calculate no. of occurrence for each set of time. However, I couldn't. For example : 0.2 -- 0.2 -- 0.21016 -- 0.21016 -- 0.21016 -- . . .... (12 Replies)
Discussion started by: ENG_MOHD
12 Replies

3. Shell Programming and Scripting

Awk program for calculating dates.

Hi All, I have a txt file which has hundreds of lines and 41 fields. I have a requirement to pick up field 14 from the text file which is a date fiels in the following format. Field 14 : Data Type : NUMERIC DATE (YYYYMMDD) Field Length : 8 Example of Data :20090415 Field 42 : Data Type... (2 Replies)
Discussion started by: nua7
2 Replies

4. Shell Programming and Scripting

[Solved] awk calculating between lines

Hey guys, maybe you can help me with this... I want to read input.dat line by line, while doing a simple calculation between the second column value of the current line and the second column value of the next line (like a difference). input is something like this: 0 3.945757 1 ... (1 Reply)
Discussion started by: origamisven
1 Replies

5. Shell Programming and Scripting

AWK way of calculating growth

Hi All, IS there any 'awk' way to manipulate following data? Fruit Date Count Apple 20/08/2011 5 Apple 27/08/2011 7 Apple 05/09/2011 11 Apple 12/09/2011 3 Apple 19/09/2011 25 . . . . Orange 20/08/2011 9 Orange 27/08/2011 20 Orange 27/08/2011 7 Orange 05/09/2011 15 Orange... (3 Replies)
Discussion started by: aniketdixit
3 Replies

6. Shell Programming and Scripting

Calculating the epoch time from standard time using awk and calculating the duration

Hi All, I have the following time stamp data in 2 columns Date TimeStamp(also with milliseconds) 05/23/2012 08:30:11.250 05/23/2012 08:30:15.500 05/23/2012 08:31.15.500 . . etc From this data I need the following output. 0.00( row1-row1 in seconds) 04.25( row2-row1 in... (5 Replies)
Discussion started by: ks_reddy
5 Replies

7. Shell Programming and Scripting

Calculating average with awk

I need to find the average from a file like: data => BW:123 M:30 RTD:0 1 0 1 0 0 1 1 1 1 0 0 1 1 0' data => BW:123 N:30 RTD:0 1 0 1 0 0 1 1 1 1 0 0 1 1 0' data => BW:123 N:30 RTD:0 1 0 1 0 0 1 1 1 1 0 0 1 1 0' data => BW:123 N:30 RTD:0 1 0 1 0 0 1 1 1 1 0 0 1 1 0' data => BW:123 N:30 RTD:0 1... (4 Replies)
Discussion started by: Slagle
4 Replies

8. Shell Programming and Scripting

Calculating Running Variance Using Awk

Hi all, I am attempting to calculate a running variance for a file containing a column of numbers. I am using the formula variance=sum((x-mean(x))^2)/(n-1), where x is the value on the current row, and mean(x) is the average of all of the values up until that row. n represents the total number... (1 Reply)
Discussion started by: Jahn
1 Replies

9. UNIX for Dummies Questions & Answers

Calculating cumulative frequency using awk

Hi, I wanted to calculate cumulative frequency distribution of my data that involves several arithmetic calls. I did things in excel but its taking me forever. this is what I want to do: var1.txt contains n observations which I have to compute for frequency which is given by 1/n and subsequently... (7 Replies)
Discussion started by: ida1215
7 Replies

10. UNIX for Beginners Questions & Answers

Calculating correlations across columns in awk

Hello, I came across a previous thread "awk-calculating-simple-correlation-rows" which calculated correlations across rows in awk. Code: awk '{ a = 0; for (i = 2; i <= NF; ++i) a += $i; a /= NF-1 b = 0; for (i = 2; i <= NF; ++i) b += ($i - a) ^ 2; b = sqrt(b) if... (7 Replies)
Discussion started by: Ross
7 Replies
pork(1) 							   USER COMMANDS							   pork(1)

NAME
pork - An AOL Instant Messenger client for the UNIX console. VERSION
version 0.99.0 SYNOPSIS
pork [options] DESCRIPTION
Pork is a console based client for the AOL Instant Messenger service that uses the ncurses screen library. Pork is intended to be fast, useable, and stable. Pork was written by Ryan McCabe. OPTIONS
-H or --host <addr> Use the local address specified for outgoing connections -p or --port <port> Use the local port specified for the main connection -h or --help Display this help text -v or --version Display version information and exit USAGE
To log into AIM, type /connect <username>, where <username> is your AIM screen name. If you don't have an AIM screen name, you can get one at http://aim.aol.com. Pork now supports IRC. The syntax for connecting to an IRC server is /connect -irc <username> <server>[:<port>[:<password>]] [... <serverN>[:<port>[:<password>]]] When you're inside the client, type /help to find out what commands are supported. Type /help <command> to get help on a particular com- mand. Below are the default key bindings. All keys can have their bindings changed or removed completely. Enter the commands '/help bind' and '/help keys' for more information. KEY BINDINGS
Default main key bindings: CTRL+A Move the cursor to the start of the line. CTRL+B Move the cursor to the start of the previous word. CTRL+E Move the cursor to the end of the line. CTRL+F Move the cursor to the start of the next word. CTRL+H Backspace. META+BACKSPACE Delete the previous word on the input line. CTRL+K Close the current window. CTRL+L Refresh the display. CTRL+T Toggle timestamps on messages. CTRL+U Clear the input line. CTRL+X Switch to the next window in the window list. CTRL+Y Switch to the previous window in the window list. TAB Switch the input focus to the buddy list. META+/ Command auto-completion. META+<1-9> Switch to the window having the specified number. HOME Scroll to the top of the display. END Scroll to the bottom of the display. PAGE UP Scroll the display up one page. PAGE DOWN Scroll the display down one page. UP ARROW Scroll the input history list up. DOWN ARROW Scroll the input history list down. CTRL+META+X Bind the next account to the current window. Default buddy list key bindings: END Move the buddy list cursor to the bottom of the buddy list. HOME Move the buddy list cursor to the top of the buddy list. PAGE UP Move the buddy list cursor one page up. PAGE DOWN Move the buddy list cursor one page down. UP ARROW Move the buddy list cursor up. DOWN ARROW Move the buddy list cursor down. ENTER Collapse the group the cursor is on, or if the cursor is on a user, open a conversation window with that user (or go to the conversation window, if one already exists). TAB Switch to main input focus. CTRL+L Refresh the buddy list display. META+p Remove the user under the cursor from the permit list. META+P Add the user the cursor is on to the permit list. META+b Remove the user the cursor is on from the block list. META+B Add the user the cursor is on to the block list. META+w Warn the user the cursor is on. META+W Warn the user the cursor is on anonymously. a Get the away message of the user the cursor is on. i Get the profile and away message of the user the cursor is on. CTRL+X Switch to the next window in the window list. CTRL+Y Switch to the previous window in the window list. FILES
~/.pork/porkrc - The pork configuration file ~/.pork/screenname.blist - The buddy list for "screenname" BUGS
ryan@numb.org - Please report bugs to this address HOMEPAGE
http://dev.ojnk.org AUTHORS
Pork was written by Ryan McCabe <ryan@numb.org>. This manpage was written by Benjamin Seidenberg <astronut@dlgeek.net>. Pork AIM Client July, 2005 pork(1)
All times are GMT -4. The time now is 09:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy