How to format number/string in ksh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to format number/string in ksh
# 1  
Old 07-02-2005
How to format number/string in ksh

Hi,
How to format a number in ksh. For example

x=RANDOM $$

I want x to be of 20 digits long, so if x = 12345 I want it to be left paded with 15 zeros.

Thanks.
# 2  
Old 07-02-2005
typeset -Z20 x
# 3  
Old 07-03-2005
Works fine - Thanks.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to filter string between specific string in ksh

My argument has data as below. 10.9.9.85 -rwxr-xr-x user1 2019-10-15 17:40 /app/scripts/testingscr5.scr 127869538 -rwxr-xr-x user1 2019-10-15 17:40 /app/scripts/testingscr56scr 127869538 ....... (note all these between lines will start with hyphen '-' ) -rwxr-xr-x user1 2019-10-15 17:40... (3 Replies)
Discussion started by: mohtashims
3 Replies

2. UNIX for Beginners Questions & Answers

Concatenate a string and number and compare that with another string in awk script

I have below code inside my awk script if ( $0 ~ /SVC IN:/ ) { svc_in=substr( $0,23 , 3); if (msg_start == 1 && msg_end == 0) { msg_arr=$0; } } else if ( $0 ~ /^SVC OUT:/ ) { svc_out=substr( $0, 9, 3); if (msg_start == 1 && msg_end == 0) ... (6 Replies)
Discussion started by: bhagya123
6 Replies

3. Shell Programming and Scripting

Extract number part from the string in ksh 88

I have to extract number part (Date and timestamp part ) from the following 3 strings AB_XYZA_20130930183017.log AB_DY_XYZA_20130930183017.log AB_GZU_20130930183017.log Output should be 20130930183017 Please help me to get the string like above Thanks (2 Replies)
Discussion started by: smile689
2 Replies

4. Shell Programming and Scripting

How to format String in ksh

Hi, I have 3 columns to display to target file and the display of the columns with specified position in target file. I have tried with printf command The Columns position like: Column1= 0 to 30 Column2=30 to 60 Column3=60 to 90 The source data: EMPNO,ENAME,SAL 1,11,100 2,22,200... (4 Replies)
Discussion started by: koti_rama
4 Replies

5. Shell Programming and Scripting

ksh scripting- array format

Hi Everyone, I have a ksh script that queries a database. The query output looks like this: $queryResult = echo ${queryResult} = name1 echo ${queryResult} = age1 echo ${queryResult} = name2 echo ${queryResult} = age2 ... I need to insert those values into a new array that would... (2 Replies)
Discussion started by: practitioner
2 Replies

6. Shell Programming and Scripting

change output format using ksh

I have a script that reaches out to several systems and pulls back infomation in serveral files. I would like to take the infomation returned and reformat it so I can export it to excel. Below is current output: File1:item1:abc=1 File1:item2:efg File2:item1:ab=1 File2:item2:efg... (3 Replies)
Discussion started by: oldman2
3 Replies

7. Shell Programming and Scripting

changing number in bash (number is in form of string)

I have a txt file as database. when i run my program what it does is it ask me for 3 name and stored in the file as name1:name2:name3:1 when u enter 3 name it add those in file as above format and add 1 at the end. I what i want is if i enter same names again it changes that 1 to 2 and so... (3 Replies)
Discussion started by: Learnerabc
3 Replies

8. Shell Programming and Scripting

Number/string format in bash

I would like to change the format of an integer type number adding zeros to the left of it in a script in bash. For example number=1 echo $number 00001 Thanks (3 Replies)
Discussion started by: josegr
3 Replies

9. Shell Programming and Scripting

String format in KSH script

Hello, I am attempting to format the output of my unix ksh script. Currently looks like ... FTP TO HR : Down FTP FROM HR 4011a : Up FTP FROM HR 4019a : Down FTP FROM HR : Down Would like the status to be aligned as follows: ... (4 Replies)
Discussion started by: dvella
4 Replies

10. Shell Programming and Scripting

format decimal in ksh

hi all, in ksh, how do i format a decimal number (e.g 3381.19) to integer (e.g 3381). This number is average time response for server in millisec and i wanted to display it in a more readable format i.e in seconds without any decimals. thanks in advance. (2 Replies)
Discussion started by: cesarNZ
2 Replies
Login or Register to Ask a Question