What operating system are you using? What version of the Korn shell are you using?
On OS X, with ksh version sh (AT&T Research) 93u+ 2012-08-01, the following script (using the variables you specified in your 1st post):
Code:
#!/bin/ksh
for number_of_positions in 2 4
do for input_string in 345987 1345987
do output_string=$(printf "%'.*f\n" $number_of_positions \
$input_string)
printf 'number_of_positions=%d\n' $number_of_positions
printf 'input_string=%s\n' $input_string
printf 'Output=%s\n\n' "$output_string"
done
done
I want to be able to generate a random number within a korn shell script..
Preferably i would like to be able to state how many digits should be in this random number... ie 4 digits or 5 digits etc
Any ideas? (2 Replies)
I have a file like this:
Tue Apr 15 10:41:47 MDT 2008 FINAL RESULT; 6
Tue Apr 15 10:41:47 MDT 2008 FINAL RESULT; 2
Tue Apr 15 10:41:47 MDT 2008 FINAL RESULT; 5
With this command seira=`cut -f 2 -d ';' tes.txt` i take all the results (6,2,5 etc) and i store them in variable seira
When i do... (9 Replies)
I am writing a script to keep check on free disk space, and I would like to find a way to parse $LINE (see code below) into a numeric value (for free disk space percentage) and a string value (for mount point). If possible, I would like to avoid sed or any additional use of awk since I am not very... (7 Replies)
I'm writing a KSH script that will get a file on the command line (such as input.txt), and in this file there is on number per line. The program needs to take the file, read each and determine the lowest number in the file. I currently have a while loop setup that will correctly out put every... (8 Replies)
Hi everybody, I have a string stored in a variable called record:
record="SNMPv2-SMI::ent.9.9.43.1.3.9.2 = Timeticks: (177330898) 20 days, 12:35:08.98"
I want to write some regular expressions good for Korn Shell to extract the number between parenthesis, in this case 177330898, and put it in... (3 Replies)
I have a task. The scenario is like this. I have a operation program (OPR1) , whose function is to simply double the (single)value it receives as input.
I have to write a script to operate the OPR1 and save its output in a file.
Later, I have to modify the script so as to be able to operate ... (0 Replies)
hello,
i have a variable which should have following content :
var="value1"
or
var="value2"
or
var="value2:*" # example: value2:22
how can i check :
- if the content is ok (value1 / value2* )
- the two options of "value2"
when content is example "value2:22" , i want to split... (3 Replies)
Anyone ever seen this? Someone mentioned this the other day....
If you do, for instance, in korn shell, echo $(5.2+2.5), it gives the result of 6 regardless.
Can't remember why but it was the limitation of the korn shell. (5 Replies)
Discussion started by: psychocandy
5 Replies
LEARN ABOUT PLAN9
uconvert
uconvert(3alleg4) Allegro manual uconvert(3alleg4)NAME
uconvert - High level string encoding conversion wrapper. Allegro game programming library.
SYNOPSIS
#include <allegro.h>
char *uconvert(const char *s, int type, char *buf, int newtype, int size);
DESCRIPTION
Higher level function running on top of do_uconvert(). This function converts the specified string `s' from `type' to `newtype', storing at
most `size' bytes into the output `buf' (including the terminating null character), but it checks before doing the conversion, and doesn't
bother if the string formats are already the same (either both types are equal, or one is ASCII, the other is UTF-8, and the string con-
tains only 7-bit ASCII characters).
As a convenience, if `buf' is NULL it will convert the string into an internal static buffer and the `size' parameter will be ignored. You
should be wary of using this feature, though, because that buffer will be overwritten the next time this routine is called, so don't expect
the data to persist across any other library calls. The static buffer may hold less than 1024 characters, so you won't be able to convert
large chunks of text. Example:
char *p = uconvert(input_string, U_CURRENT, buffer, U_ASCII, 256);
RETURN VALUE
Returns a pointer to `buf' (or the static buffer if you used NULL) if a conversion was performed. Otherwise returns a copy of `s'. In any
cases, you should use the return value rather than assuming that the string will always be moved to `buf'.
SEE ALSO set_uformat(3alleg4), need_uconvert(3alleg4), uconvert(3alleg4), uconvert_ascii(3alleg4), uconvert_toascii(3alleg4), do_uconvert(3alleg4)Allegro version 4.4.2 uconvert(3alleg4)