Apparently your sed doesn't understand the [[:digit:]] class, but if it did, it would replace the first digit -- the 1 in 1989 -- and replace it with a literal string "[[:digit:]]". You need to supply more context; and, apparently, use the old-fashioned [0-9] construct for matching a digit.
The regular expression matches a single digit after an underscore, and captures it into a backreference so you can refer to it as "\1" in the substitution part. (That's what the backslashed parentheses are for. Your sed might want them without backslashes, or something.) The /g at the end says to do this as many times as possible ("globally"), not just on the first occurrence.
Thanks Era,
Your approach looks simple, but not quite right. Shamrock's method below looks long, but it gives me a right answer.
I found below script to check whether the variable is a digit in ksh.
############################
#!/bin/ksh
REPLY="3f"
if ]*\)'` != ${REPLY} && "${REPLY}" != "0" ]]
then
print "is digit\n"
else
print "not digit\n"
fi
############################
Although it works fine, but... (6 Replies)
Hi All,
How can i convert a number 24 to 0024
In the same way how can i convert 123 to 0123?
All this has to be done inside a script
Thanks in advance
JS (6 Replies)
I have a var storing date
var=`date`
Now the date is returned as
Mon Feb 2 00:25:48 PST 2009
Is there any way to check the date field alone ("2" in above case) and if its a single digit then add a prefix 0 to it and store the result in same variable "var"
My intention in above case is... (3 Replies)
Hi,
I have a text file with content as follows:
bla foo3200492
comment on this: 3900302
here comes the teddy 12
all I need is:
3200492
3900302
12
So I need the correct "sed" command to delete everything until the first number.
I am not a regex expert, because I have to... (3 Replies)
hi All,
i want to add the single digit front of the line in the report file and string compare with pattern file.
patter file: pattern1.txt
pattern num
like 4
love 3
john 2
report file: report.txt
i like very much
but john is good boy
i will love u
so after execute... (9 Replies)
Hi,
I am trying to create a csv from a existing flat file.I am using the same data to create the csv file. But I have issues \10 columns onwards..
sed... (5 Replies)
Hello!
My final exam in my Linux class is tomorrow, and I was just reviewing the grep and sed commands. I came across an example, by which I got stumped: it asks to provide a sed command that deletes all lines that contain exactly 3 to 5 digit strings, from a file.
In this case, I created a... (3 Replies)
Like I have below string
XX_49154534_491553_201_122023_D
XX_49159042_491738_201_103901_D
and the expected output would be
0154534
0159042
XX and 49 can be dynamic. (1 Reply)
Discussion started by: nadeemrafikhan
1 Replies
LEARN ABOUT DEBIAN
algorithm::checkdigits::m10_009
CheckDigits::M10_009(3pm) User Contributed Perl Documentation CheckDigits::M10_009(3pm)NAME
CheckDigits::M10_009 - compute check digits for Betriebsnummer (DE)
SYNOPSIS
use Algorithm::CheckDigits;
$betrnr = CheckDigits('betriebsnummer');
if ($betrnr->is_valid('73282932000074')) {
# do something
}
$cn = $betrnr->complete('7328293200007');
# $cn = '73282932000074'
$cd = $betrnr->checkdigit('73282932000074');
# $cd = '4'
$bn = $betrnr->basenumber('73282932000074');
# $bn = '7328293200007'
DESCRIPTION
ALGORITHM
1. Beginning left all numbers are weighted alternatively 1 and 2.
2. The total of the digits of all products is computed.
3. The sum of step 3 ist taken modulo 10.
4. The check digit is the difference between 10 and the number from step 3 taken modulo 10.
HINT: The last digit of the 'Betriebsnummer' may be the check digit or the last digit of the sum of the constant 5 and the check digit.
METHODS
is_valid($number)
Returns true only if $number consists solely of numbers and the last digit is a valid check digit according to the algorithm given
above.
Returns false otherwise,
complete($number)
The check digit for $number is computed and concatenated to the end of $number.
Returns the complete number with check digit or '' if $number does not consist solely of digits and spaces.
basenumber($number)
Returns the basenumber of $number if $number has a valid check digit.
Return '' otherwise.
checkdigit($number)
Returns the checkdigit of $number if $number has a valid check digit.
Return '' otherwise.
EXPORT
None by default.
AUTHOR
Mathias Weidner, <mathias@weidner.in-bad-schmiedeberg.de>
SEE ALSO
perl, CheckDigits, www.pruefziffernberechnung.de. www.dsi.cnrs.fr/bureau_qualite/admindonnees/documents/siren.pdf
perl v5.10.0 2008-05-17 CheckDigits::M10_009(3pm)