Search Results

Search: Posts Made By: balajesuri
5,041
Posted By balajesuri
#! /bin/bash shopt -s extglob x=$1 ...
#! /bin/bash

shopt -s extglob

x=$1
while [ ${#x} -gt 0 ]
do
num=${x%%[a-zA-Z]*}; x=${x##+([0-9])}
str=${x%%[0-9]*}; x=${x##+([a-zA-Z])}
for ((i=1; i<=$num; i++))
do
...
5,041
Posted By balajesuri
Your code takes 0.02s on my machine!! I'm working...
Your code takes 0.02s on my machine!! I'm working on a server having 6 quad core cpu's each clocking 2.4 GHz and running on RHEL.

Try this. I don't claim it to be the most efficient. But still...
5,041
Posted By balajesuri
@max_hammer: I don't think [ "$x" =~ [0-9] ]...
@max_hammer: I don't think [ "$x" =~ [0-9] ] would work on bash 3.2 either.

I'm using GNU bash, version 3.2.25 and [ "$x" =~ [0-9] ] doesn't work. Regex matching is not supported by single square...
5,041
Posted By balajesuri
Try with double brackets.. like this: if [[...
Try with double brackets.. like this:
if [[ "${ch}" =~ "[0-9]" ]]
5,041
Posted By balajesuri
$ cat input 3a3b4c 4a5d2c 10a12b14c ...
$ cat input
3a3b4c
4a5d2c
10a12b14c
3abc4xyz5pqr
$
$ perl -ne 'chomp;print$2x$1while(/(\d+)(\D+)/g);print"\n"' input
aaabbbcccc
aaaadddddcc
aaaaaaaaaabbbbbbbbbbbbcccccccccccccc...
Showing results 1 to 5 of 5

 
All times are GMT -4. The time now is 04:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy