# algorithm::checkdigits::m11_013(3pm) [debian man page]

```CheckDigits::M11_013(3pm)				User Contributed Perl Documentation				 CheckDigits::M11_013(3pm)

NAME
CheckDigits::M11_013 - compute check digits for VAT Registration Number (GR)

SYNOPSIS
use Algorithm::CheckDigits;

\$ustid = CheckDigits('ustid_gr');

if (\$ustid->is_valid('123456783')) {
# do something
}

\$cn = \$ustid->complete('12345678');
# \$cn = '123456783'

\$cd = \$ustid->checkdigit('123456783');
# \$cd = '3'

\$bn = \$ustid->basenumber('123456783');
# \$bn = '12345678';

DESCRIPTION
ALGORITHM
1.  Beginning right with the digit before the checkdigit all digits are weighted with 2 ** position. I. e. the last digit is multiplied
with 2, the next with 4, then 8 and so on.

2.  The weighted digits are added.

3.  The sum from step 2 is taken modulo 11.

4.  If the sum from step 3 is greater than 9, the check sum is 0 else it is the sum itself.

METHODS
is_valid(\$number)
Returns true only if \$number consists solely of numbers and hyphens and the two digits in the middle are valid check digits according
to the algorithm given above.

Returns false otherwise,

complete(\$number)
The check digit for \$number is computed and inserted into the middle of \$number.

Returns the complete number with check digit or '' if \$number does not consist solely of digits, hyphens and spaces.

basenumber(\$number)
Returns the basenumber of \$number if \$number has a valid check digit.

Return '' otherwise.

checkdigit(\$number)
Returns the check digits of \$number if \$number has valid check digits.

Return '' otherwise.

EXPORT
None by default.

AUTHOR

perl, CheckDigits, www.pruefziffernberechnung.de,

perl v5.10.0							    2008-05-17						 CheckDigits::M11_013(3pm)```

## Check Out this Related Man Page

```CheckDigits::M97_001(3pm)				User Contributed Perl Documentation				 CheckDigits::M97_001(3pm)

NAME
CheckDigits::M97_001 - compute check digits for VAT Registration Number (BE)

SYNOPSIS
use Algorithm::CheckDigits;

\$ustid = CheckDigits('ustid_be');

if (\$ustid->is_valid('136695962')) {
# do something
}

\$cn = \$ustid->complete('1366959');
# \$cn = '136695962'

\$cd = \$ustid->checkdigit('136695962');
# \$cd = '62'

\$bn = \$ustid->basenumber('136695962');
# \$bn = '1366959'

DESCRIPTION
ALGORITHM
1.  The whole number (without checksum) is taken modulo 97.

2.  The checksum is difference of the remainder from step 1 to 97.

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 checkdigits of \$number if \$number has a valid check digit.

Return '' otherwise.

EXPORT
None by default.

AUTHOR

perl, CheckDigits, www.pruefziffernberechnung.de.

perl v5.10.0							    2008-05-17						 CheckDigits::M97_001(3pm)```
Man Page

## Write a shell program to find the sum of alternate digits in a given 5-digit number

Hi Can any one please post the answer for the above program..................

## to check if a string has only digits

Hi guys, I am not very experienced in writing ksh scripts and I am trying to write a piece of code that indicates if a given string contains only digits and no alphabet (upper or lower case). If i write it my way it would turn out to have a lot of comparisons.. :eek: Thanks a lot in...

## awk or substr

i have a variable 200612 the last two digits of this variable should be between 1 and 12, it should not be greater than 12 or less than 1 (for ex: 00 or 13,14,15 is not accepted) how do i check for this conditions in a unix shell script. thanks Ram

## Stripping all content but an integer

Hello! I have content in a log file that consists of a lot of spaces before and after a 3 digit integer which I need to strip out before I can use the file. The number of digits can change. When I had my logic in a 'for' loop and could output into another file, it was fine. but it turns out...

## ksh Checking if variable has 5 digits

How could I check if a numeric variable has 5 digits in KSH...I have a zipcode variable that I know will always be 5 digits, and I want to print out an error if it is less or more than 5 digits the problem is that I have it as: if ] but this won't work because the statement doesn't see 0001 as...

## adding zeroes to all single digits

I have got a file that contains both single and double digits like this 10 3 48 39 20 6 8 and i want to add zeros in front of every single digit to become double digits like this 10 03 48 39 20 06 08 I tried using Sed sed 's/\(\)/0&/g' filename or sed 's/\(\)*/0&/g' filename but i...

## help: single digits inflated to 2 digits

Hi Folks Probably an easy one here but how do I get a sequence to get used as mentioned. For example in the following I want to automatically create files that have a 2 digit number at the end of their names: m@pyhead:~\$ for x in \$(seq 00 10); do touch file_\$x; done m@pyhead:~\$ ls file*...

## how to use grep: finding a string with double quotes and multiple digits

I have a file with a lot of lines (a lot!) that contain 10 digits between double quotes. ie "1726937489". The digits are random throughout, but always contain ten digits. I can not for the life of me, (via scouring the internet and grep how-to manuals) figure out how to find this when I search....

## Use match() in nawk to find digits in number

Hi, I just need to check whether number of digits in a phone number is 10 or not. If I am not wrong regex will be: {9} I have to use this inside nawk as this is a small portion of a big program. nawk ' BEGIN { RS="";FS=";"; regex="{9}"; } { for (i=1;i<=NF;i++) { if...

## find digit which is greater than 1000 in text -using shellscript

Hi All, I am having an abc.txt , which contains some digits Eg:abc.txt 145 566 355 I want write shellscript in suchway that if any digit is greter than 1000 then it shuld display " text files contain digit, which is greater than 1000" Please help me to do so Thanks..

## Split a file into multiple files based on first two digits of file.

Hi , I do have a fixedwidth flatfile that has data for 10 different datasets each identified by the first two digits in the flatfile. 01 in the first two digit position refers to Set A 02 in the first two digit position refers to Set B and so on I want to genrate 10 different files from my...

## extracting Number variable and the following digits.

HI all, I have output of something like this: crab: ExitCodes Summary >>>>>>>>> 12 Jobs with Wrapper Exit Code : 50117 List of jobs: 1-12 See https:///twiki/something/ for Exit Code meaning crab: ExitCodes Summary >>>>>>>>> 5 Jobs with Wrapper Exit Code : 8001 List of...

## Check and control params in parsing file

Hello, I would like to control and check the right parameters \$1 must have 4 alphabetics digits among eora qora pora fora \$2 must have 2 numerics digits 00 to 11 \$3 must have 2 numerics digits 00 to 59 \$4 must have 10 characters alpha numerics as 2013-02-26 For example : In case 5) if i...

## Sum in terabyte

Hello, can someone help me in this I have a file of sizes in kilobyte I want to caculte the sum in terabyte using awk I would like to have one digit after the decimal point ( 2.8 TB for example) cat file 2881301319 3061567196 3010347398 3029693706 2906516319 2444536488...

## Find number of digits in a word

HI, Can you tell me how to find the number of digits in a word. \$cat data.txt +123456ad 87645768 Output should be 6 8