Sponsored Content
Full Discussion: Padding
Top Forums UNIX for Dummies Questions & Answers Padding Post 37725 by vijaygopalsk on Thursday 26th of June 2003 03:23:06 PM
Old 06-26-2003
Padding

Hi

Can anyone tell me how to pad zeroes on the left side to a numeric string in unix shell scripting

Your answer is very much appreciated

Thanks
Vijay
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Padding issues

Hello, Structure padding & structure size are different on Compaq & HP UNIX. When structures are transfered via netfork from Compaq to HP will this be a problem? If yes, what can be the solution? Thanks, shilpa (2 Replies)
Discussion started by: informshilpa
2 Replies

2. Programming

Zero Padding to a string

I am writing a C program which a part of it needs to padding zero in front of a string. The program will get a sting from an ASCII file which the maxium length of this string is 5 char long. The string can sometimes less the 5 char long. In order to make it with the same length '0's are being... (3 Replies)
Discussion started by: Wing m. Cheng
3 Replies

3. Programming

Padding variables

Is there a function in c that will allow me to pad variables? I have an int that can't be longer than 10. I need to pad a numeric value with leading zeros 314 0000000314 (1 Reply)
Discussion started by: flounder
1 Replies

4. Programming

Byte Padding

Hi, Can someone explain what is byte padding? For ex: struct emp{ char s; int b; char s1; int b1; long b3; char s3; } What will be the size of this structure? Thanks (6 Replies)
Discussion started by: naan
6 Replies

5. Shell Programming and Scripting

Padding in Unix

I have a file with different character counts on each line how do i make it with unique character counts. example: 1st line : ABCD 011 XYZ 0000 YYYY BBB TEADINGDA 2nd line: ABCD 011 xys 0010 YYYY BBB TEAD 3rd line : ABCD 022 YXU 000 UUU BBB TE 1st line is 43... (3 Replies)
Discussion started by: rudoraj
3 Replies

6. UNIX for Dummies Questions & Answers

Zero padding dates

I have a file with records containing dates like: SMPBR|DUP-DO NOT USE|NEW YORK||16105|BA5270715|2007-6-6|MWERNER|109||||JOHN||SMITH|MD|72211118||||||74559|21 WILMINGTON RD||D|2003-11-6|SL# MD CONTACT-LIZ RICHARDS|||0|Y|N||1411458| How can I get the date fields in each of my records to be... (1 Reply)
Discussion started by: ChicagoBlues
1 Replies

7. Shell Programming and Scripting

Padding with zeros.

Hi Friends, I would like to left pad with "0's" on first column say (width six) I have a large file with the format: FILE: 1: ALFRED 84378 NY 8385: JAMES 88385 FL 323: SMITH 00850 TX My output needs to be like: 000001: ALFRED 84378 NY 008385: JAMES 88385 FL 000323: SMITH... (10 Replies)
Discussion started by: sbasetty
10 Replies

8. Shell Programming and Scripting

Padding leading zero

hi All i am new to linux... source txt .. 281-BUM-5M BUM-5M 0 0 282-BUM-5M BUM-5M 0 0 83-BUM-5M BUM-5M 0 0 is it possible to use bash script to convert to (remove the "-" and fill up to 4 digit" ? 0281 BUM-5M BUM-5M 0 0 0282 BUM-5M BUM-5M 0 0 0083 BUM-5M BUM-5M 0 0 thanks a ... (5 Replies)
Discussion started by: samoptimus
5 Replies

9. Shell Programming and Scripting

bash padding

Hi all Is there a way to pad the output of a bash script see that code below for i in `sed -n '/Start Printer/,/End Printer/p' /u/ab/scripts/hosts.conf | awk '!/^#/ {print $2}' | egrep -v 'broke|primera' `; do pages=`snmpget -Ov -v1 -c public $i sysLocation.0 | awk '{print $2}'` ... (3 Replies)
Discussion started by: ab52
3 Replies

10. Shell Programming and Scripting

Padding a csv value with 0's

I have this csv file that I would like to sort on the 20th and 21st field. They are high lighted below. My challenge is that when I sort on those fields they are not in order as I would have liked. It seems like I have to pad those fields to the longest value in that fields data. ... (6 Replies)
Discussion started by: GroveTuckey
6 Replies
newpad(3XCURSES)					  X/Open Curses Library Functions					  newpad(3XCURSES)

NAME
newpad, pnoutrefresh, prefresh, subpad - create or refresh a pad or subpad SYNOPSIS
cc [ flag... ] file... -I /usr/xpg4/include -L /usr/xpg4/lib -R /usr/xpg4/lib -lcurses [ library... ] c89 [ flag... ] file... -lcurses [ library... ] #include <curses.h> WINDOW *newpad(int nlines, int ncols); int pnoutrefresh(WINDOW *pad, int pminrow, int pmincol, int sminrow, int smincol,int smaxrow, int smaxcol); int prefresh(WINDOW *pad, int pminrow, int pmincol, int sminrow, int smincol,int smaxrow, int smaxcol); WINDOW *subpad(WINDOW *orig, int nlines, int ncols); PARAMETERS
nlines Is the number of lines in the pad to be created. ncols Is the number of columns in the pad to be created. pad Is a pointer to the pad to refresh. pminrow Is the row coordinate of the upper left corner of the pad rectangle to be copied pmincol Is the column coordinate of the upper left corner of the pad rectangle to be copied. sminrow Is the row coordinate of the upper left corner of the rectangle on the physical screen where pad is to be positioned. smincol Is the column coordinate of the upper left corner of the rectangle on the physical screen where pad is to be positioned. smaxrow Is the row coordinate of the lower right corner of the rectangle on the physical screen where the pad is to be positioned. smaxcol Is the column coordinate of the lower right corner of the rectangle on the physical screen where the pad is to be positioned. orig Is a pointer to the parent pad within which a sub-pad is created. DESCRIPTION
The newpad() function creates a new pad with the specified number of lines and columns. A pointer to the new pad structure is returned. A pad differs from a window in that it is not restricted to the size of the physical screen. It is useful when only part of a large window will be displayed at any one time. Automatic refreshes by scrolling or echoing of input do not take place when pads are used. Pads have their own refresh commands, pre- fresh() and pnoutrefresh(). The prefresh() function copies the specified portion of the logical pad to the terminal screen. The parameters pmincol and pminrow spec- ify the upper left corner of the rectangular area of the pad to be displayed. The lower right coordinate of the rectangular area of the pad that is to be displayed is calculated from the screen parameters (sminrow, smincol, smaxrow, smaxcol). This function calls the pnoutrefresh() function to copy the specified portion of pad to the terminal screen and the doupdate(3XCURSES) function to do the actual update. The logical cursor is copied to the same location in the physical window unless leaveok(3XCURSES) is enabled (in which case, the cursor is placed in a position that the program finds convenient). When outputting several pads at once, it is often more efficient to call the pnoutrefresh() and doupdate() functions directly. A call to pnoutrefresh() for each pad first, followed by only one call to doupdate() to update the screen, results in one burst of output, fewer characters sent, and less CPU time used. The subpad() function creates a sub-pad within the pad orig with the specified number of lines and columns. A pointer to the new pad structure is returned. The sub-pad is positioned in the middle of orig. Any changes made to one pad affect the other. touchwin(3XCURSES) or touchline(3XCURSES) will likely have to be called on pad orig to correctly update the window. RETURN VALUES
On success, the newpad() and subpad() functions returns a pointer to the new pad data structure. Otherwise, they return a null pointer. On success, the pnoutrefresh() and prefresh() functions return OK. Otherwise, they return ERR. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
clearok(3XCURSES), doupdate(3XCURSES), is_linetouched(3XCURSES), libcurses(3XCURSES), pechochar(3XCURSES), attributes(5), standards(5) SunOS 5.11 5 Jun 2002 newpad(3XCURSES)
All times are GMT -4. The time now is 07:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy