Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 2,288
Thanks Given: 430
Thanked 480 Times in 395 Posts
Hi.
Here is a short perl script, but note that it will fail on numbers that contain decimal points:
Producing:
This is similar to the code found in the Perl Cookbook, and at several places on the net. It has the advantage of being to able to do the work without extracting the integer string -- if something doesn't look like an integer, it skips over it. It will not skip leading zeros, nor add the $ for you -- just basic comma insertion.
There are pure shell functions that can do the same thing. Balancing the sizes of the codes and the size of the interpreters, I'd usually chose the sed solution. However, if one is doing something in awk or perl, one can use these methods directly in the code. I like the brevity of the perl script, made possible by regular expressions.
Hi,
I have a dynamically growing ascii file which has large data (both text and digits). I need to grep those lines having value greater than '123'. These numeric values may appear at anywhere in the line, hence I could not use awk to split to columns.
So, please help me with the grep regular... (12 Replies)
in a shell script, i hav a variable declared as "ABC-123".
i want to incriment th value ABC-123 by 1 so that the result will be
ABC-124.
Can anyone suggest a solution in shell scripting.. (4 Replies)
suppose u have a file
ABC ADFA AFAF AGBA AHHAH
AJJA AJKA AJAJ AJAJA AJAJAJ
AHAB AAAJ AJAJA AKK AJAJAA
means gaps have to replaced and see also there will be gaps so output shud be
ABCADFAAFAFAGBAAHHAHAJJAAJKAAJAJAJAJAAJAJAJAHABAAAJJAJAAKKAJAJAA
Thanks (2 Replies)