03-28-2002
string test?
hey guys- what is the syntax for a string test to verify that a user has entered a 6 digit numeric?
Thanks for your help in advance!
Todd
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Okay I will let users input spaces as well :)
I am having a mental block. I have done a couple of searches but havent found anything that I understand (the likes of :alpha: and awk).
Basically I want to give the user an option to enter some text which will go down as a field within a flat... (3 Replies)
Discussion started by: tugger
3 Replies
2. UNIX for Dummies Questions & Answers
Hi! I'm using
echo $string | grep "" -c
to test in a script if a string is a number and it seems to work. But how can i find, for example, if a string is a four figures number ?
Thanks to all! (2 Replies)
Discussion started by: Kaminski
2 Replies
3. Shell Programming and Scripting
This is the code:
while test 1 -eq 1
do
read a
$a
if test $a = stop
then
break
fi
done
I read a command on every loop an execute it.
I check if the string equals the word stop to end the loop,but it say that I gave too many arguments to test.
For example echo hello.
Now the... (1 Reply)
Discussion started by: Max89
1 Replies
4. Shell Programming and Scripting
How to check weather a string is like test* or test* ot *test* in if condition (5 Replies)
Discussion started by: johnjerome
5 Replies
5. Shell Programming and Scripting
How do I test multiple words in a string test like below:
if ]
then
print "You entered $TBS name.\n"
else
print "You entered an incorrect response.\n"
fi
This test does not work. I have tried different syntax versions. How does this work? And is there a better way to do it?
... (10 Replies)
Discussion started by: djehresmann
10 Replies
6. Shell Programming and Scripting
Hi there, I have a bunch of interface names like
e1000g0
nge1
dmfe3
I also have some that have longer (vlan tagged) names
like
e1000g123001
nge23003
e1000g999002
I need to determine whether the interface is one of the former or latter types and I would do that by seeing... (7 Replies)
Discussion started by: rethink
7 Replies
7. Shell Programming and Scripting
How do I use bash to test whether a string occurs more than two times in a file? (2 Replies)
Discussion started by: locoroco
2 Replies
8. Shell Programming and Scripting
How do I use bash to test if a line begins with a random number of spaces followed by a letter? (1 Reply)
Discussion started by: locoroco
1 Replies
9. Shell Programming and Scripting
Hi guys
I am performing a simple test for a blank string with the following code:
if ] ]] ; then
echo "Blanks are NOT a valid input "
return 1
fi
The above fails giving a syntax error message:
syntax error at line 142 : `=~' unexpected
I am in ksh88
is there... (2 Replies)
Discussion started by: aoussenko
2 Replies
10. Shell Programming and Scripting
I want to find whether string values are available in a field of a file. Let it be any character other than number . I just want to know whether characters will be available in it . Please share a single step command for this without creating a shell script. (5 Replies)
Discussion started by: Sang
5 Replies
LEARN ABOUT ULTRIX
vfprintf
vprintf(3int) vprintf(3int)
Name
vprintf, vfprintf, vsprintf - print formatted output of a varargs argument list
Syntax
#include <stdio.h>
#include <varargs.h>
int vprintf ( format, ap )
char *format;
va list ap;
int vfprintf ( stream, format, ap )
FILE *stream;
char *format;
va list ap;
int vsprintf ( s, format, ap )
char *s, *format;
va list ap;
Description
The international functions and are similar to the standard I/O functions.
Likewise, the vprintf functions are similar to the printf functions except they are called with an argument list as defined by instead of
with a variable number of arguments.
The international functions allow you to use the %digit$ conversion character in place of the % character you use in the standard I/O
functions. The digit is a decimal digit n from 1 to 9. The international functions apply conversions to the nth argument in the argument
list, rather than to the next unused argument.
You can use the % conversion character in the international functions. However, you cannot mix the % conversion character with the %digit$
conversion character in a single call.
You can indicate a field width or precision by an asterisk (*) instead of a digit string in format strings containing the % conversion
character. If you use an asterisk, you can supply an integer arg that specifies the field width or precision. In format strings containing
the %digit$ conversion character, you can indicate field width or precision by the sequence *digit$. You use a decimal digit from 1 to 9
to indicate which argument contains an integer that specifies the field width or precision.
The conversion characters and their meanings are identical to
You must use each digit argument at least once.
Examples
#include <stdio.h>
#include <varargs.h>
main()
{
char *function_name = "vpr";
char *arg1 = "hello world";
int arg2 = 2;
char *arg3 = "study";
char *i18nfmt = "%1$s %3$d
";
test(function_name, i18nfmt, arg1, arg2, arg3);
}
test(va_alist)
va_dcl
{
va_list args;
char *fmt;
char string[1024];
va_start(args);
(void)printf("function %s: ", va_arg(args, char *));
fmt = va_arg(args, char *);
(void)vprintf(fmt, args);
va_end(args);
}
See Also
setlocale(3), scanf(3int), printf(3s), printf(3int), vprintf(3s), putc(3s), scanf(3s), stdio(3s), varargs(3)
Guide to Developing International Software
vprintf(3int)