Visit Our UNIX and Linux User Community


Greping numbers with dot in it


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Greping numbers with dot in it
# 8  
Old 08-12-2009
Alternatively, a perl solution could be:

Code:
$
$ cat f1
aoforce.out:         *  zero point VIBRATIONAL energy  :      0.6725445  Hartree  *
job.last:                 |  total energy      =  -3842.57456191055  |
$
$ perl -lne 'chomp; @x=split; foreach $i(@x){if ($i =~ /\d+/){$s += $i; print $i}}END{print "Sum = ",$s}' f1
0.6725445
-3842.57456191055
Sum = -3841.90201741055
$
$

tyler_durden

Previous Thread | Next Thread
Test Your Knowledge in Computers #874
Difficulty: Medium
A programming language is homoiconic if a program written in it can be manipulated as data using the language, and thus the program's internal representation can be inferred just by reading the program itself.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Ommit the numbers or any characters only at 8th columns after the dot (.).

Ommit the numbers or any characters only at 7th or 8th columns after the dot (.) . Since the group column has 1 and 2 spaces. Thanks -rw-r--r--. 1 user1 domain users 619 2017-04-13 16:16:50.284598383 +0000 aa drwxr-xr-x. 2 root root 6 2017-05-08... (8 Replies)
Discussion started by: invinzin21
8 Replies

2. Shell Programming and Scripting

How i can add via preg replace dot after numbers ?

So lets say i have file my_birthday.402.zip ho it can became my_birthday.4.0.2.zip Thank you :) (1 Reply)
Discussion started by: ZerO13
1 Replies

3. Shell Programming and Scripting

greping $2 into a list

Hi When I run this command: lsuser -a auditclasses ALL I got: user1 auditclasses=general,objects,cron,files,rbac,audit,lvm,aixpert user2 auditclasses=general,objects,cron,files,rbac,audit,lvm,aixpert user3 auditclasses=general,objects,cron,files,rbac,audit,lvm,aixpert user4... (7 Replies)
Discussion started by: iga3725
7 Replies

4. Shell Programming and Scripting

need help in greping

Hi, i have to find a string in a file and positin of the string in the file would come in some particular interval. let's say file is 1-1000 lines and string is in from 200-300line. could any one suggest me how to get make the grep search for the string in that particular portion of the... (4 Replies)
Discussion started by: tarakant
4 Replies

5. Shell Programming and Scripting

Greping in between two different lines.

I know you could use the grep "something" -A200 flag to get all the lines past your pattern. Is there a way to get all the lines in between two patterns? The -a flag will not work since all lines in between the two patterns don't have a constant number. (4 Replies)
Discussion started by: jwillis0720
4 Replies

6. Shell Programming and Scripting

greping ip address

I have this line BTSRTRGRP-448-1-1 10.162.141.118/255.255.255.254 - I need to print only the IPADDRESS and not the subnet mask. If i use cut -c30-43 I get the ipaddress, where as in some cases if the last octet is of single digit (10.162.141.8/255.255.255.254) it... (2 Replies)
Discussion started by: miltonrods
2 Replies

7. Shell Programming and Scripting

need help in greping

i have a ksh script : #!/bin/ksh TZ=`date +%Z`+24 ;a=`date +%Y-%m-%d` b=`date +"%H:%M:%S"` cd /ednadtu3/u01/pipe/logs for i in Archiver1.log do cat $i | grep $a | grep $b >> /ednadtu3/u01/pipe/naveed/Insert_Date.txt done... (4 Replies)
Discussion started by: ali560045
4 Replies

8. Shell Programming and Scripting

Greping certain lines

One of my outout is like this as shown below. How can I grep only the lines after the line "Affected files ...". No of lines after the line "Affected files ..." may vary. $ cat file_A Change 149133 by csaha@test_depo_csaha on 2006/02/08 01:40:57 *pending* This is to test change #... (5 Replies)
Discussion started by: csaha
5 Replies

9. UNIX for Dummies Questions & Answers

GREPing for Nulls

I just had a filesystem / file corruption issue on my HSP's server due to disk capacity limits and fileswapping. I discovered that certain files got corrupted when fileswapping was not successful and they ended up with a string of control characters, or what I believe to be nulls, in them. Does... (4 Replies)
Discussion started by: Dr. DOT
4 Replies

10. UNIX for Dummies Questions & Answers

Help with greping a field

Hi, Suppose I have a file as below and I just want the field Invoice Number from this file , How can I do it. /home/arbor>cat PH0034090202314800030IM-001 0Yp825XMilperra NSW 1891 189110H14V1Sp2871Yp300X Customer Service : 0000-368-81118H6.5V0Sp3130Yp50X ... (7 Replies)
Discussion started by: rooh
7 Replies
inet(3N)																  inet(3N)

NAME
inet: inet_addr(), inet_lnaof(), inet_makeaddr(), inet_netof(), inet_network(), inet_ntoa(), inet_ntoa_r() - Internet address manipulation routines SYNOPSIS
Remarks The routine is described in the section below. DESCRIPTION
Interpret character strings representing numbers expressed in the Internet standard "dot" notation. returns numbers suitable for use as Internet addresses. returns numbers suitable for use as Internet network numbers. Return values can be assigned to a (defined in by using a technique similar to the following: Take an Internet address and return an ASCII string representing the address in dot notation. Take an Internet network number and a local network address and construct an Internet address from it. Break apart Internet host addresses, returning the network number part. Break apart Internet host addresses, returning the local network address part. All Internet addresses are returned in network order (bytes ordered from left to right). All network numbers and local address parts are returned as machine-format integer values. Bytes in HP-UX systems are ordered from left to right. Internet Addresses Values specified using dot notation take one of the following forms: When four parts are specified, each is interpreted as a byte of data and assigned, from left to right, to the four bytes of an Internet address. When a three-part address is specified, the last part is interpreted as a 16-bit quantity and placed in the right-most two bytes of the network address. This makes the three-part address format convenient for specifying Class B network addresses, as in When a two-part address is supplied, the last part is interpreted as a 24-bit quantity and placed in the right-most three bytes of the net- work address. This makes the two-part address format convenient for specifying Class A network addresses as in When only one part is given, the value is stored directly in the network address without any byte rearrangement. All numbers supplied as parts in dot notation can be decimal, octal, or hexadecimal, as specified in the C language (i.e., a leading 0x or 0X implies hexadecimal; a leading 0 implies octal; otherwise, the number is interpreted as decimal). In a multithreaded application, uses thread-specific storage that is re-used in each call. The return value, the character string, should be unique for each thread and should be saved, if desired, before the thread makes the next call. Obsolescent Interfaces The following reentrant interface has been moved from to It is included to support existing applications and may be removed in a future release. New multithreaded applications should use the reg- ular API (those without the suffix.) The reentrant interface functions the same as the regular interface without the suffix. However, expects to be passed the address of a character buffer and will store the result at the supplied location. If the buffer is of insufficient length, is returned. If the opera- tion is successful, the length of the result string (not including the terminating null character) is returned. RETURN VALUE
The routines return values as described in the section. and return for malformed requests. WARNINGS
The return value from the function cannot distinguish between a failure (and a local broadcast address (255.255.255.255). This can be han- dled by using the function instead of the function. AUTHOR
The routines were developed by the University of California, Berkeley. SEE ALSO
gethostent(3N), getnetent(3N), inet6(3N), hosts(4), networks(4), thread_safety(5). inet(3N)

Featured Tech Videos