Sponsored Content
Full Discussion: Pad Zeros at the end
Top Forums Shell Programming and Scripting Pad Zeros at the end Post 302581395 by greenworld123 on Tuesday 13th of December 2011 05:56:38 AM
Old 12-13-2011
i have shell script
Code:
 
While <read file>
do
ecode=`echo $line | cut -d"|" -f4`
length=`echo $line | cut -d"|" -f5`
 
example ecode will have 
34628
23492759
523489573
156232
123414
1233
 
length=10
 
output
3462800000
2349275900
 
i need to append zeros at the end of the each based on the length field

 

7 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

pad Zeros

Hi can I know command to pad Zeros to a value I get 16 and I need to send 0000000016 (5 Replies)
Discussion started by: mgirinath
5 Replies

2. Shell Programming and Scripting

Pad zeros to a number

Pad zeros to a number and assign it to a variable like i get 1 in $i ,i want it to be $i as 01 (6 Replies)
Discussion started by: anumkoshy
6 Replies

3. Programming

How to right pad with zeros using sprintf?

I need to right-pad with zeros a string by using (s)printf. I looked up the manual and tried with printf("%-19s", buffer); which right-pad the string with spaces. So I tried printf("%019s", buffer); which left-pad the string with zeros. So I tried both printf("%-019s", buffer);... (9 Replies)
Discussion started by: emitrax
9 Replies

4. Shell Programming and Scripting

Reformat a string and pad space at the end

I need to read in the string from input file and reform it by cut each segment and check the last segement lenght. If the last segment length is not as expected (see below segment file or table. It is predefined), then pad enough space. Old string FU22222222CA6666666666AKxvbFMddreeadBP999... (1 Reply)
Discussion started by: menglm
1 Replies

5. Shell Programming and Scripting

Pad space at the end of string and reformat

I need to read in the string from input file and reform it by cut each segment and check the last segement lenght. If the last segment length is not as expected (see below segment file or table. It is predefined), then pad enough space. Old string FU22222222CA6666666666AKxvbFMddreeadBP999... (11 Replies)
Discussion started by: menglm
11 Replies

6. Shell Programming and Scripting

How to pad with leading zeros for current time?

I'm using cygwin bash to submit scheduled tasks (kinda like cron jobs) in windows and the following script is giving me grief. I need to format the current time with leading zeros before 10AM for the hour field. In this example, I manually typed in "09:50" instead of using the `printf...`... (2 Replies)
Discussion started by: siegfried
2 Replies

7. UNIX for Beginners Questions & Answers

Pad 0 to the right

I need to pad 0 to a number on the right. to make it 9 digit in total. My number is 2457 output should be 245700000 Please do wrap your samples/codes into CODE TAGS as per forum rules. (3 Replies)
Discussion started by: varun22486
3 Replies
GAI_STRERROR(3) 					   BSD Library Functions Manual 					   GAI_STRERROR(3)

NAME
gai_strerror -- get error message string from EAI_xxx error code SYNOPSIS
#include <sys/types.h> #include <sys/socket.h> #include <netdb.h> const char * gai_strerror(int ecode); DESCRIPTION
The gai_strerror() function returns an error message string corresponding to the error code returned by getaddrinfo(3) or getnameinfo(3). The following error codes and their meaning are defined in <netdb.h>: EAI_AGAIN temporary failure in name resolution EAI_BADFLAGS invalid value for ai_flags EAI_BADHINTS invalid value for hints EAI_FAIL non-recoverable failure in name resolution EAI_FAMILY ai_family not supported EAI_MEMORY memory allocation failure EAI_NONAME hostname or servname not provided, or not known EAI_OVERFLOW argument buffer overflow EAI_PROTOCOL resolved protocol is unknown EAI_SERVICE servname not supported for ai_socktype EAI_SOCKTYPE ai_socktype not supported EAI_SYSTEM system error returned in errno RETURN VALUES
The gai_strerror() function returns a pointer to the error message string corresponding to ecode. If ecode is out of range, an implementa- tion-specific error message string is returned. SEE ALSO
getaddrinfo(3), getnameinfo(3) BSD
May 21, 2006 BSD
All times are GMT -4. The time now is 07:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy