Sponsored Content
Top Forums Shell Programming and Scripting Greping numbers with dot in it Post 302343338 by mario8eren on Wednesday 12th of August 2009 08:14:22 AM
Old 08-12-2009
Greping numbers with dot in it

Hi,

I wanted to create a script what would take two numbers out of two files and add them together, but I got stuck with greping numbers what have a dot in it.

So far I have grepped the two lines what include the numbers I need (from both files) to a third file and from that file I try to grep only the numbers.

The third file looks like this:
Code:
aoforce.out:         *  zero point VIBRATIONAL energy  :      0.6725445  Hartree  *
job.last:                 |  total energy      =  -3842.57456191055  |

The script I have at the moment (thanks to your forums Smilie ) is like this:

Code:
grep -ho '[-0-9]\{1,20}' 

and with that script I get an output like this:

Code:
0
6725445
-3842
57456191055

But I would like an output like this:

Code:
0.6725445
-3842.57456191055



Thank you in advance,

Mario

Last edited by zaxxon; 08-12-2009 at 09:21 AM.. Reason: CODE tags
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
ncheck(8)						      System Manager's Manual							 ncheck(8)

NAME
ncheck - lists i-number or tag and path name for files in a local file system. SYNOPSIS
/usr/sbin/ncheck [-i numbers] [-asm] file_spec [file_spec...] PARAMETERS
Specifies one or more file systems. Specify any file system by entering its full path name or its mount point. The full path name is the name entered in the file-spec field of the file system's entry in the /etc/fstab file. The mount point is the name entered in the mnt_point field of the file system's entry in the /etc/fstab file. You can also specify a UFS file system by entering the name of its device special file. For example: /dev/disk/dsk3c. You can also specify an AdvFS fileset by entering the name of the file domain, a pound sign (#) character, and the name of the file- set. For example: root_domain#root. FLAGS
Includes in the list the path names . (dot) and .. (dot dot), which are ordinarily suppressed. Lists only those files with the specified i-numbers (UFS) or tags (AdvFS). If you enter a zero (0) all allocated numbers will be displayed. Includes in the list the mode, UID, and GID of the files. To use this flag you must also specify either the -i or the -s flag on the command line. Lists only the special files and files with set-user-ID mode. DESCRIPTION
The ncheck command with no flags generates a list of all files on every specified file system. The list includes the path name and the corresponding i-number or tag of each file. Each directory file name in the list is followed by a /. (slash dot). Use the available flags to customize the list to include or exclude specific types of files. The files are listed in order by i-number or tag. To sort the list in a more useful format, pipe the output to the sort command. NOTES
The term file_spec represents either a UFS file system or an AdvFS fileset. To uncover concealed violations of security policy, that is, the inappropriate use of the set-user-ID mode, issue the command with the -s flag to list only special files and files with set-user-ID mode. RESTRICTIONS
You must be the root user to use this command. The ncheck command checks the /etc/fstab file for the specified domain and file system entry. If there is no entry in /etc/fstab for the specified file system, an error message is displayed to indicate that the file does not exist. DIAGNOSTICS
When the file system structure is improper, ?? (question mark question mark) denotes the parent of a parentless file. A path name begin- ning with ... (dot dot dot) denotes a loop. ERRORS
The ncheck command can be used only for checking local file systems. The "nnn" string identifies the file system type. FILES
Specifies the command path RELATED INFORMATION
sort(1), quot(8). delim off ncheck(8)
All times are GMT -4. The time now is 07:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy