10-16-2013
Putting white Space at the end of the string
Hi Guys,
Hope, you all are doing good out there.
I am writing a shell script and currrint in need of your help.
This is what I need to do;
I have position based plain file. One of the fields is 15 character long. I need to fill that field. The problem is that the value is dynamic, it could be 4, 8, 10, 13 or 15 characters long. It is quite possible that most of the time the value is not 15 character long.
If the value is less than 15, then I need to add the no of exact white spaces to make it up to 15.
For examle, the string is "
ERI-STD-W800I". Here, the length of the string is 13, so I need to add 2 white spaces at the end of it. So, the string will be "
ERI-STD-W800I ".
Can you please help me in achieving this?
A prompt help will be highly appreciated.
Regards,
Chandan Singh
Moderator's Comments:
|
|
Using font changes and bold text do not adequately replace CODE (or ICODE) tags when spacing is important.
|
|
Last edited by Don Cragun; 10-16-2013 at 02:08 PM..
Reason: Remove extraneous font changes, change bold characters to ICODE tags; correct spacing.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi All;
Having a problem with a file..
the file contains the following data... (a snapshot)
1331F9E9DB7C2BB80EAEDE3A8F043B94,AL7 1DZ,M,50
186FDF93E1303DBA217279EC3671EA91,NG5 1JU,M,24
3783FFAF602015056A8CD21104B1AAAF,CH42 4NQ,M,17
It has 3 columns sepreated by a ,
the second column... (7 Replies)
Discussion started by: Zak
7 Replies
2. Programming
I am coding a C program to read a plain text file. There are a lot of blank fields or a string with white spaces. I want to know is there such a function called trim() in C to clean the white space around a string? Or some other way can do this efficiently? Thanks. (18 Replies)
Discussion started by: hxm1303
18 Replies
3. UNIX for Dummies Questions & Answers
Dear Members,
Suppose i have a variable test which stores a string as below:
test='John drives+++++++++a+++++car'
now i want to use sed on the above variable and replace + with a white space, so that i get
echo $test should give me
'john drives a car'
Between... (1 Reply)
Discussion started by: sandeep_1105
1 Replies
4. Shell Programming and Scripting
Im trying to add 5 blank spaces to the end of each line in a file in a sed script. I can figure out who o put the spaces pretty much anywhere else but at the end.
thanks
Karl (7 Replies)
Discussion started by: karlanderson
7 Replies
5. Shell Programming and Scripting
Hi,
What sed command (if sed is the right command) can remove ALL white space from my file. I have a csv, except I want to remove all white space between commas and characters.
My idea (without testing)
sed 's/ //g'
Is there a better way? (18 Replies)
Discussion started by: mcclunyboy
18 Replies
6. Shell Programming and Scripting
Suppose, I have a variable var=" name is ".
I want to remove the blank spaces from the begining and endonly, not from the entire string.
So, that the variable/string looks like following
var="name is".
Please look after the issue. (3 Replies)
Discussion started by: mady135
3 Replies
7. Shell Programming and Scripting
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
8. Shell Programming and Scripting
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
9. Shell Programming and Scripting
Hi,
I am trying to remove lines once a string is found till another string is found including the start string and end string. I want to basically grab all the lines starting with color (closing bracket). PS: The line after the closing bracket for color could be anything (currently 'more').... (1 Reply)
Discussion started by: Dabheeruz
1 Replies
10. Shell Programming and Scripting
hi guys
how can i add spacein file name with sed if strings have no space around dash
input
19-20
( 18-19 )
ABC-EFG
output after add white space
19 - 20
(18 - 19 )
ABC - EFG
thx in advance (2 Replies)
Discussion started by: mhs
2 Replies
LEARN ABOUT XFREE86
psign
PSIGN(1) General Commands Manual PSIGN(1)
NAME
psign - produce a RADIANCE picture from text.
SYNOPSIS
psign [ options ] [ text ]
DESCRIPTION
Psign produces a RADIANCE picture of the given text. The output dimensions are determined by the character height, aspect ratio, number of
lines and line length. (Also the character size if text squeezing is used.) If no text is given, the standard input is read.
-cb r g b Set the background color to r g b The default is white (1 1 1).
-cf r g b Set the foreground color to r g b The default is black (0 0 0).
-dr Text reads to the right (default).
-du Text reads upwards.
-dl Text reads to the left (upside down).
-dd Text reads downwards.
-h cheight
Set the character height to cheight. The default is 32 pixels.
-a aspect Set the character aspect ratio (height/width) to aspect. The default value is 1.67.
-x xsize Set the horizontal image size to xsize. Use with -y option (below) in place of the -h specification to control output image size
directly. If the character aspect ratio (-a option, above) is non-zero, then one of the specified x or y output dimensions may
be reduced to maintain this ratio. If direction is right (-dr) or left (-dl), then it is not necessary to give the -y option,
since it can be computed from the character height (-h).
-y ysize Set the vertical image size to ysize. Use with the -x option (described above). If direction is up (-du) or down (-dd), then it
is not necessary to give the -x option, since it can be computed from the character height (-h).
-s spacing
Set the intercharacter spacing to spacing. The magnitude of this value is multiplied by the character height over the aspect
ratio (ie. the character width) to compute the desired distance between characters in the output. The sign of the value, posi-
tive or negative, determines how this ideal spacing is used in the actual placement of characters. If spacing is positive, then
the overall width of the line will not be affected, nor will indentation of textual elements. Thus, the text format will be
mostly unaffected. However, spacing between characters will reflect their relative size for a more natural appearance. If spac-
ing is negative, characters will be squeezed together to meet the spacing critereon, regardless of how it might affect the format
of the output. The default value for spacing is zero, which is interpreted as uniformly spaced characters.
-f fontfile
Load the font from fontfile. The default font is helvet.fnt
EXAMPLE
To put a big "Hi!" on the terminal:
psign -h 22 -a 1 -cb 0 0 0 -cf 1 1 1 Hi! | ttyimage
ENVIRONMENT
RAYPATH path to search for font files
AUTHOR
Greg Ward
BUGS
The entire bitmap is stored in memory, which can be a problem for large and/or high-resolution signs.
SEE ALSO
getinfo(1), pcompos(1), pfilt(1), ttyimage(1)
RADIANCE
10/9/97 PSIGN(1)