Sponsored Content
Top Forums Shell Programming and Scripting Removing comma just from numbers Post 302575435 by Johanni on Monday 21st of November 2011 04:18:21 PM
Old 11-21-2011
Removing comma just from numbers

Hi Guys,

I want to remove commas from just the numbers in the file.
So both sides of the comma should be numbers.

Input file

Code:
Johan
1,234 nb
jan
123,3
hi, hello, bye
12,345,54
hejhej

Desired output:

Code:
Johan
1234 nb
jan
1233
hi, hello, bye
1234554
hejhej

Thanks a lot Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

removing all numbers from file

I have one me.txt file like aaa 765 gfre 534 jhk 321 cvvb 98 hftg 2 bdg2 hfuk 65 etc.. now I want to remove all numbers form that file using shell script and out put will be printed in me1.txt output: aaa gfre jhk cvvb hftg bdg hfuk please help me. (2 Replies)
Discussion started by: rinku
2 Replies

2. UNIX for Dummies Questions & Answers

Removing comma after 3rd column

I have 10,000 lines to remove the commas after the 3rd column. Any help will be appreciated! Removing commas after the 3rd column Input aaaaa,bbbbb,cccccc,ddddddd aaaaa,bbbbb,cccccc aaaaa,bbbbb,cccccc,ddddddd,eeeeee aaaaa,bbbbb,cccccc,ddddddd,eeeeee,fffffff........(limit of comma is not... (13 Replies)
Discussion started by: buddyme
13 Replies

3. Shell Programming and Scripting

sed removing comma inside double quotes

I have a csv file with lines like the followings 123456,"ABC CO., LTD","XXX" 789012,"DEF LIMITED", "XXX" before I bcp this file to database, the comma in "CO.," need to be removed first. My script is cat <filename> | sed 's/"CO.,"/"CO."/g' but it doesn't work. Can anyone here able to... (2 Replies)
Discussion started by: joanneho
2 Replies

4. UNIX for Dummies Questions & Answers

validate a pattern of numbers that are comma separated

Hi, I have a requirement wherein, I need to validate a user input of the numbers that are comma separated. E.g . The input should be in the format 1,2,3...n (count of numbers is not known) . The user has to mention the input in this format, else it should exit from the program. ... (5 Replies)
Discussion started by: 12345
5 Replies

5. Shell Programming and Scripting

Removing Line numbers

Hi all, I have a file consisting of lines in such a format: separated by space and M1 EOS for fullstop (.) ] e.g M1 I M1 have M1 a M1 file M1 consisting M1 of M1 lines M1 in M1 such M1 a M1 format M1 EOS M2 This M2 is M3 an (4 Replies)
Discussion started by: my_Perl
4 Replies

6. Shell Programming and Scripting

Removing Numbers

Hi, Below is a scattered representation of numbers . 1 2 11 22 11 22 1 2 1 2 11 22 1 2 11 22 I need to display only the following sequence "" and delete of the remainder from the output. The output should look like (2 Replies)
Discussion started by: Ananth12
2 Replies

7. UNIX for Dummies Questions & Answers

Need help removing leading spaces from one field in comma seperated file

Using awk or sed, I'd like to remove leading spaces after a comma and before a right justified number in field 6. Sounds simple but I can't find a solution. Each field's formatting must stay intact. Input: 40,123456-02,160,05/24/2012,02/13/1977, 10699.15,0 Output:... (5 Replies)
Discussion started by: Scottie1954
5 Replies

8. UNIX for Dummies Questions & Answers

Awk: Wondering how to format numbers with comma

I have tried the following commands and can't get a number to format with commas: echo 1234567.12 |awk '{printf("%-12s %20s\n", $0, comma($0)) }' This prints out value 50000 without a comma for i in *13*; do (cd $i && du -sk . && echo $i);done|grep -v 0000|gawk -F OFS="," ' {SUM += $1}... (8 Replies)
Discussion started by: newbie2010
8 Replies

9. Shell Programming and Scripting

awk to parse comma separated field and removing comma in between number and double quotes

Hi Experts, Please support I have below data in file in comma seperated, but 4th column is containing comma in between numbers, bcz of which when i tried to parse the file the column 6th value(5049641141) is being removed from the file and value(222.82) in column 5 becoming value of column6. ... (3 Replies)
Discussion started by: as7951
3 Replies

10. Shell Programming and Scripting

Sum up formatted numbers with comma separation

I need to sum up the values in field nr 5 in a data file that contains some file listing. The 5th field denotes the size of each file and following are some sample values. 1,775,947,633 4,738 7,300 16,610 15,279 0 0 I tried the following code in a shell script. awk '{sum+=$5} END{print... (4 Replies)
Discussion started by: krishmaths
4 Replies
NUMGREP(1)						User Contributed Perl Documentation						NUMGREP(1)

NAME
numgrep - This program is the numeric equivilent of the grep utility. SYNOPSIS
numgrep [-dhlV] <FILE> | numgrep [-dhlV] (Input on STDIN from pipeline.) numgrep [-dhlV] (Input on STDIN. Use Ctrl-D to stop.) DESCRIPTION
numgrep searches for different occurances of numbers through the use of numeric expressions. OPTIONS
-l Print the matching numbers out one per line instead of printing the entire line they are on. -h Help: You're looking at it. -V Increase verbosity. -d Debug mode. For developers EXPRESSIONS
numgrep uses a special numeric expression matching system. Basically, it searches for ranges, factors and sequences of numbers. Here is a list of the syntax characters and some sample expressions that will get you going: /<expression>/ Put your expression or set of expressions between these two forward slashes. .. Range expression. A number must be used on the left and/or right of this expression to specify that numbers between, greater than or less than the numbers specified should be matched. , Expression sepeartor. The comma sepearates one complete expression from another in a set enclosed by //. m<n> Multiples of <n>. This operator, followed by a number <n> will match any number <x> that is an integer multiple of <n>. Meaning that <x> = <n> times <y>, where <y> is any integer. f<n> Factors of <n>. This operator, followed by a number <n> will match any number <x> that is an integer factor of <n>. Meaning that <x> = <n> divided by <y>, where <y> is any integer. NOTE: Checking for factors and multiples is very fast because it is checked by doing a single modulus operation on two numbers. Examples: /2..10/ Match any number between 2 and 10. /2..10,20..30/ Match any number between 2 and 10 or between 20 and 30. /56,34,512,45,67/ Match any of the numbers 56, 34, 512, 45 or 67. /m3/ Match any integer that is a multiple of 3. /f1024/ Match any integer that is a factor of 1024. $ numrange -N /1..1000/ | numgrep /f1024/ 1 2 4 8 16 32 64 128 256 512 $ BUGS
numgrep can't handle certain situations properly. Such as if it encounters a number with leading zeros, it will treat it as an octal number and thus might not match the way you would expect. numgrep does not yet allow you to mix numbers and text in the matching expression. So you can not do something like 'numgrep /port=0..1023/ firewall.log'. But this will be changed in the future. SEE ALSO
numaverage(1), numbound(1), numinterval(1), numnormalize(1), numprocess(1), numsum(1), numrandom(1), numrange(1), numround(1) COPYRIGHT
numgrep is part of the num-utils package, which is copyrighted by Suso Banderas and released under the GPL license. Please read the COPYING and LICENSE files that came with the num-utils package Developers can read the GOALS file and contact me about providing submitions or help for the project. BUGS
numgrep will round decimal numbers with more than 15 digits of accuracy. This is mostly due to limit's in the way programming languages deal directly with numbers. MORE INFO
More info on numgrep can be found at: http://suso.suso.org/programs/num-utils/ perl v5.10.1 2009-10-31 NUMGREP(1)
All times are GMT -4. The time now is 10:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy