04-08-2008
Ksh Checking if string has 2 characters and does not contain digits?
How could I check if a string variable contains at least (or only) 2 characters, and check and make sure that the string does not contain any numeric digits?...I need to know how to do this as simple as possible. and I am using the Ksh shell. Thanks.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
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... (3 Replies)
Discussion started by: lakshmikanth
3 Replies
2. Shell Programming and Scripting
I have a string like xxxxxx44. What's the best way to extract the digits (one or more) in a ksh script?
Thanks (6 Replies)
Discussion started by: offirc
6 Replies
3. UNIX for Dummies Questions & Answers
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... (3 Replies)
Discussion started by: developncode
3 Replies
4. Shell Programming and Scripting
print out 201 in following string, Please note the chars before 201 are random, no fixed format.
ua07app201 (20 Replies)
Discussion started by: honglus
20 Replies
5. Shell Programming and Scripting
Hi all,
i have such string stored in a variable
var1 = 00000120
i want the o/p
var1 = 120
is it possible to have such o/p in ksh/bash ...
thanx in advance for the help
sonu (3 Replies)
Discussion started by: sonu_pal
3 Replies
6. UNIX for Dummies Questions & Answers
Hello,
i have a file called test
hello1
"how" are you4
good"bye"
good7bye
i am trying to print all lines from test that either end with a digit or contain a double quote character anywhere on the line.
i did
grep -n '$' test and was able to print lines ending with digits.
i also did... (2 Replies)
Discussion started by: hobiwhenuknowme
2 Replies
7. Shell Programming and Scripting
I would like to search between two a string. I thought this would be easy. The is always at the beginning of a line.
The code:
gawk '/^/{d=$1},/searchstring/,/^(d+1)/'
or
gawk '/^/,/searchstring/,/^/'
did not return the desired result.
inputfile.txt
999 some text searchstring some... (6 Replies)
Discussion started by: sdf
6 Replies
8. Shell Programming and Scripting
Hi All,
I am trying to find non-printable characters in a string. The sting could have alphanumeric, puntuations and characters like (*&%$#.') but not non-printable (or that is what I think they are called) which are introduced when you copy any text from DOS to unix box.
Input string1:... (10 Replies)
Discussion started by: dips_ag
10 Replies
9. Shell Programming and Scripting
Hello,
I have a log file with logs such as
01/05/2017 10:23:41 : file.log.38: database error, MODE=SINGLE, LEVEL=critical, STATE: 01170255 (mode main
how can i use perl to extract the 8-digit number below from the string
01170255
Thanks (7 Replies)
Discussion started by: james2009
7 Replies
10. Shell Programming and Scripting
I am using the below to random generate a password but I need to have 2 numeric characters and 6 alphabetic chars
head /dev/urandom | tr -dc A-Za-z0-9 | head -c 8 ; echo ''
6USUvqRB
------ Post updated at 04:43 PM ------
Any Help folks - Can the output be passed onto a sed command to... (9 Replies)
Discussion started by: infernalhell
9 Replies
LEARN ABOUT DEBIAN
algorithm::checkdigits::m11_011
CheckDigits::M11_011(3pm) User Contributed Perl Documentation CheckDigits::M11_011(3pm)
NAME
CheckDigits::M11_011 - compute check digits for VAT Registration Number (NL)
SYNOPSIS
use Algorithm::CheckDigits;
$ustid = CheckDigits('ustid_nl');
if ($ustid->is_valid('123456782')) {
# do something
}
if ($ustid->is_valid('123456782B04')) {
# do something
}
$cn = $ustid->complete('12345678');
# $cn = '123456782'
$cn = $ustid->complete('12345678.B04');
# $cn = '123456782B04'
$cd = $ustid->checkdigit('123456782');
# $cd = '2'
$cd = $ustid->checkdigit('123456782B04');
# $cd = '2'
$bn = $ustid->basenumber('123456782');
# $bn = '12345678';
$bn = $ustid->basenumber('123456782B04');
# $bn = '12345678.B04';
DESCRIPTION
This VATRN has 12 "digits", the third last must be a B, the fourth last is the checkdigit. I don't know anything about the meaning of the
last two digits.
You may use the whole VATRN or only the first eight digits to compute the checkdigit with this module.
ALGORITHM
1. Beginning right with the digit before the checkdigit all digits are weighted with their position. I.e. the digit before the checkdigit
is multiplied with 2, the next with 3 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 10, the number is discarded.
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.
SEE ALSO
perl, CheckDigits, www.pruefziffernberechnung.de,
AUTHOR
Mathias Weidner, <mathias@weidner.in-bad-schmiedeberg.de>
COPYRIGHT AND LICENSE
Copyright 2004,2005 by Mathias Weidner
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.10.0 2008-05-17 CheckDigits::M11_011(3pm)