We have script like the following
But in the output file spaces are truncated and Output is coming like the below
please advise
Moderator's Comments:
Please wrap all code, files, input & output/errors in CODE tags.
It makes them far easier top read and preserves multiple spaces for indenting or fixed-width data
Last edited by rbatte1; 07-24-2015 at 12:30 PM..
Reason: CODE tags
Welcome to forum, kindly use code tags for commands/inputs/codes which you are using in your posts as per forum rules. You should use printf for same because it is known behavior for echo.
Hope this helps, enjoy learning and sharing knowledge in forum
Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
The difference is in the quoting. The shell will strip out multiple spaces.
Use echo "$a$b$c" instead.
Better still, you should also use {&} around variable names to clearly mark where they start and end and printf instead of echo so you would end up with:-
Unfortunately, echo can vary between vendors.
The difference is in the quoting. The shell will strip out multiple spaces.
Use echo "$a$b$c" instead.
Better still, you should also use {&} around variable names to clearly mark where they start and end and printf instead of echo so you would end up with:-
Unfortunately, echo can vary between vendors.
Robin
The echo is dangerous if any if the first variable expands to a string starting with a hyphen or if any of the variables expand to a string containing any backslash characters. Otherwise:
is fine. But, if you're reading data from a user supplied source, never assume that you know what the data will contain, and, as Robin suggested, use printf instead.
But:
is also dangerous (and doesn't add the trailing <newline> character that echo would provide). The dangers are the same as with echo but has an additional problem if the expansion of any of those variables contain a <percent-sign> character. The safe way to print three variables (with no added space between them and with a trailing <newline>) would be:
You only need to include braces around variable names if text following the variable name could be part of a valid variable name. For instance if you wanted to print the expansion of the variable b followed by the character b you could use either of the following:
but not either of:
since both of those you result in the expansion of the variable bb instead of the variable b. Shell variable names can contain letters, digits, and underscores where the 1st character is not a digit.
Positional parameters look like variable names just containing digits, but the rules are slightly different. Single digit positional parameters never require (but do allow) braces but multi-digit positional parameters always require braces. The expansion of $11 (or of ${1}1) will result in the expansion of the 1st positional parameter followed by the digit 1. To get the expansion of the 11th positional parameter, you must use ${11}.
This User Gave Thanks to Don Cragun For This Post:
Good afternoon! Im new at scripting and Im trying to write a script to
calculate total space, total used space and total free space in filesystem names matching a keyword (in this one we will use keyword virginia). Please dont be mean or harsh, like I said Im new and trying my best. Scripting... (4 Replies)
Operating System: Solaris 10, Shell
We are outputting the results of our scripts to the stderr file. However we have encountered a problem where some of the lines in the file are truncated.
Is there a way to increase the terminal or column size within the script so that this does not... (4 Replies)
Sir, my apologies for I had put this question in a different forum earlier.
I am running an appliction in SCO 5.6. If the records are more than one lakh, the output file is getting truncated to one lakh. Please help me in rectifying the issue whereby it allows creation of output with more than... (0 Replies)
Discussion started by: chssastry
0 Replies
4. Post Here to Contact Site Administrators and Moderators
Sir, my apologies for not being able to correspond for a long time.
I am running an appliction in SCO 5.6. If the records are more than one lakh, the output file is getting truncated to one lakh. Please help me in rectifying the issue whereby it allows creation of output with more than one lakh... (0 Replies)
I searched and could not find an answer to this, and am having difficulty, so I would appreciate any assistance that can be offered.
We're experiencing logs that are having all characters after the 850th one written being truncated. I am wondering if there is a default limit to the syslog... (1 Reply)
Operating system - Solaris 8, Korn shell, xterm
Command
/usr/proc/bin/ptree
outputs the process tree exactly as I want with all detail
However,
/usr/proc/bin/ptree | more
truncates the process descriptions at an 80 character point. If the process tree has marched enough to the right,... (3 Replies)
folks;
i need help with a truncation problem in AIX when running "ps" command. when i run ps in SUN, i got the full output but when i run it in AIX the output is truncated. is there any arguments i can pass to give longer output so i can overcome the issue?
here's the details:(please note the... (2 Replies)
Hi,
I have a program that gets called from the front end of my application. Actually it creates some temporary files and uses them and deletes them at last. But sometimes, say once in 6 times, some of these temporary files are getting truncated in the middle and because of this my program is... (9 Replies)
Hi,
I'm using the vi that comes with Solaris 2.8. When vi a file with lines that have long continuous characters e.g. more than 256 chars, these lines got truncated. This is a known limitation of the out of the box Solaris vi, and there is a suggestion to get another vi. Is there an... (0 Replies)
we aheva couple of old sun OS boxes, that we are trying to parse /usr/ucb/ps output.
However it seems that something is occuring that is causeing th output of "/usr/ucb/ps -auxwww" to cut short the process name, whereas "ps -eaf" can display the entire process name.
It will work for a while... (2 Replies)