Sponsored Content
Top Forums Shell Programming and Scripting Shell Printf command , a little more dynamic.. Post 302766007 by neutronscott on Monday 4th of February 2013 03:57:10 AM
Old 02-04-2013
Is this exactly how you wrote it? My shell gives an error due to the quoting. Which shell are you using? This works in dash, a mostly posix sh:

Code:
$ a=10 b=976461
$ c=$(printf "%0${a}d" "$b")
$ echo "$c"
0000976461

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

printf command

I want to make a logfile with error messages, like this: (collumms: CUSTNR DATE TIME ERROR MESSAGE) 102 20020807 135417 1 Uptime server is more than 6 months 5 20020808 111335 3 Backup not Ok! 2001 20020808 120428 6 Free space at server1 is less than 20% etcetera I... (2 Replies)
Discussion started by: FIRE
2 Replies

2. Shell Programming and Scripting

need help with printf command

Hi How could I use the command printf to display a big file. So ex. I've a script with some variables like: V1=358504 V2=FD0147 V3=dev5 V4=94577 V5=0 V6=UNIX V7=Policy V8=server V9=04/15/05 V10=19:18:41 V11=2341321467 while read V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 do printf "\n%s %s %s... (1 Reply)
Discussion started by: nymus7
1 Replies

3. Shell Programming and Scripting

the printf command

hello, Im at another part of the program i am writing. Where i think i'm going to need to use the printf command. If anyone can help me figure out the printf layout i would greatly appreicate it. thanks (4 Replies)
Discussion started by: bebop1111116
4 Replies

4. Shell Programming and Scripting

passing a list of dynamic names to a "PS" command in shell script?

Hi, I am new to shell script. This is my first post .I have written a small script which returns list of names starts with "ram" in /etc/passwd .Here is that:- #!/bin/ksh NAME_LIST="name_list.txt" cat /dev/null > $NAME_LIST evalcmd="cat /etc/passwd | grep "^ram?*" | cut -d: -f1" eval... (3 Replies)
Discussion started by: sachin.tendulka
3 Replies

5. Shell Programming and Scripting

Shell script dynamic command

I need to run a shell script with dynamic command in it like # Begin script... mysql xx "select * from tab" | sed 's/\t/|/g' > GENERATED_20100304.txt the dynamic part is 20100304 which should be today's date, and it needs to run every day and create a new file with... (2 Replies)
Discussion started by: nuthalapati
2 Replies

6. Shell Programming and Scripting

Printf command

Hi, I a sequance number from 1-999 and i want asing the value like 001,002..999 Exp: file_001 file_002 file_003... file_999 How can i disaplay the sequnace number as mention above. (3 Replies)
Discussion started by: koti_rama
3 Replies

7. Shell Programming and Scripting

help with printf command

hello, I'm trying to display Unix variable using printf command. Code: awk '{ if ( $0 ~ /string/ ) { printf( "%s\n%s\n",$0,"dsd"); #this one works printf( "%s\n%s\n",$0,$HOME); #this does not work } else { print $0; } }' param1_1.txt I could use here echo command but I'm... (2 Replies)
Discussion started by: bipbip
2 Replies

8. Shell Programming and Scripting

Help with printf in shell scripting

Hi all I am using printf in my shell script to format my output.I am using the following code. printf "|\tIP Address\t|\tModel Number\t|\tDOM/HW\t|\tSoftware Version\t|\n" printf "|\t%s\t|\t%s\t\t|\t%s\t|\t%s-%s\t\n" $encoder $modelno $type $sv1 $sv2 printf "|\tFPGA... (2 Replies)
Discussion started by: ramman
2 Replies

9. Shell Programming and Scripting

Need help in printf in shell script

My requirement is need to add spaces to the string with the dynamic value to printf... this is a part of shell script ..which i have , the length is not static ... length=15 value="1234567890" printf "%-"$length"s\n" "$value"; The result it is printing is ... i am not sure y it is... (19 Replies)
Discussion started by: greenworld123
19 Replies

10. Shell Programming and Scripting

Problem running plsql using printf command on bash shell

I am running plsql using printf on a shell, but i am getting some strange error, can someone point what exactly am i missing, $ echo $SHELL /bin/bash $ printf " > SET serveroutput ON trimspool on feed off echo off > declare > p_val number; > d_val varchar2(10); > begin > SELECT... (1 Reply)
Discussion started by: kamauv234
1 Replies
Shell(3X)																 Shell(3X)

NAME
Shell - The Shell widget class SYNOPSIS
#include <Xm/Xm.h> #include <X11/Shell.h> DESCRIPTION
Shell is a top-level widget (with only one managed child) that encapsulates the interaction with the window manager. At the time the shell's child is managed, the child's width is used for both widgets if the shell is unrealized and no width has been spec- ified for the shell. Otherwise, the shell's width is used for both widgets. The same relations hold for the height of the shell and its child. Classes Shell inherits behavior and resources from Composite and Core. The class pointer is shellWidgetClass. The class name is Shell. New Resources The following table defines a set of widget resources used by the programmer to specify data. The programmer can also set the resource values for the inherited classes to set attributes for this widget. To reference a resource by name or by class in a .Xdefaults file, remove the XmN or XmC prefix and use the remaining letters. To specify one of the defined values for a resource in a .Xdefaults file, remove the Xm prefix and use the remaining letters (in either lowercase or uppercase, but include any underscores between words). The codes in the access column indicate if the given resource can be set at creation time (C), set by using XtSetValues (S), retrieved by using XtGetValues (G), or is not applicable (N/A). Shell Resource Set Class: XmCAllowShellResize Default: False Type: Boolean Access: CG Class: XmCCreatePopupChildProc Default: NULL Type: XtCreatePopupChild- Proc Access: CSG Class: XmCGeometry Default: NULL Type: String Access: CSG Class: XmCOverrideRedirect Default: False Type: Boolean Access: CSG Class: XmCCallback Default: NULL Type: XtCallbackList Access: C Class: XmCCallback Default: NULL Type: XtCallbackList Access: C Class: XmCSaveUnder Default: False Type: Boolean Access: CSG Class: XmCVisual Default: CopyFromParent Type: Visual * Access: CSG Specifies that if this resource is False, the Shell widget instance returns XtGeometryNo to all geometry requests from its children. Specifies the pointer to a function that is called when the Shell widget instance is popped up by XtPopup. The function creates the child widget when the shell is popped up instead of when the application starts up. This can be used if the child needs to be recon- figured each time the shell is popped up. The function takes one argument, the popup shell, and returns no result. It is called after the popup callbacks specified by XmNpopupCallback. Specifies the desired geometry for the widget instance. This resource is examined only when the widget instance is unrealized and the number of its managed children is changed. It is to change the values of the XmNx, XmNy, XmNwidth, and XmNheight resources. Specifies this is True if the widget instance is a temporary window which should be ignored by the window manager. Applications and users should not normally alter this resource. Specifies a list of call- backs that is called when the widget instance is popped down by XtPopdown. Specifies a list of callbacks that is called when the widget instance is popped up by XtPopup. Specifies a True value if it is desirable to save the contents of the screen beneath this widget instance, avoiding expose events when the instance is unmapped. This is a hint, and an implementation may save contents whenever it desires, including always or never. Specifies the visual used in creating the widget. Inherited Resources Shell inherits behavior and resources from the following superclass. For a complete description of each resource, refer to the man page for that superclass. Composite Resource Set Class: XmCReadOnly Default: NULL Type: WidgetList Access: G Class: XmCInsertPosition Default: NULL Type: XtOrderProc Access: CSG Class: XmCReadOnly Default: 0 Type: Cardinal Access: G Core Resource Set Class: XmCAccelerators Default: dynamic Type: XtAccelerators Access: CSG Class: XmCSensitive Default: dynamic Type: Boolean Access: G Class: XmCBackground Default: dynamic Type: Pixel Access: CSG Class: XmCPixmap Default: XmUNSPECIFIED_PIXMAP Type: Pixmap Access: CSG Class: XmCBorderColor Default: XtDefaultForeground Type: Pixel Access: CSG Class: XmCPixmap Default: XmUNSPECIFIED_PIXMAP Type: Pixmap Access: CSG Class: XmCBorderWidth Default: 1 Type: Dimension Access: CSG Class: XmCColormap Default: dynamic Type: Colormap Access: CG Class: XmCDepth Default: dynamic Type: int Access: CG Class: XmCCallback Default: NULL Type: XtCallbackList Access: C Class: XmCHeight Default: dynamic Type: Dimension Access: CSG Class: XmCInitialResourcesPersistent Default: True Type: Boolean Access: C Class: XmCMapped- WhenManaged Default: True Type: Boolean Access: CSG Class: XmCScreen Default: dynamic Type: Screen * Access: CG Class: XmCSensitive Default: True Type: Boolean Access: CSG Class: XmCTranslations Default: dynamic Type: XtTranslations Access: CSG Class: XmCWidth Default: dynamic Type: Dimension Access: CSG Class: XmCPosition Default: 0 Type: Position Access: CSG Class: XmCPosition Default: 0 Type: Posi- tion Access: CSG Translations There are no translations for Shell. SEE ALSO
Composite(3X), Core(3X) Shell(3X)
All times are GMT -4. The time now is 06:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy