Format a line for output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Format a line for output
# 1  
Old 07-02-2005
Format a line for output

Hi all

I have a problem which requires me to produce a line output in a specified format. I have looked around and see that there is typeset which would do the trick to pad a variable and as such ensure that its start position in a line is always the same.

I have tried to use this, however it does not seem th work. How do I use it. My script to test this is as follows :-

#!/usr/bin/ksh
a="1234"
b="XYZ"
typeset -L10 a
typeset -L20 b
echo $a$b
a="987654"
b="zxcvbb"
echo $a$b


and the out is
1234 XYZ
987654 zxcvbb


whereas it should be
"1234______XYZ"
"987654____zxcvbb"


Any ideas ?

Thx
J
# 2  
Old 07-02-2005
echo "$a$b"
# 3  
Old 07-04-2005
Modify the echo command as

echo "$a \t $b"

I hope this will solve the problem of alignment.

If required u can add more "\t" to provide more spaces between the strings.
# 4  
Old 12-07-2006
Question

i found that actually the \t could not align the column. got any other idea or not? Smilie
# 5  
Old 12-07-2006
maybe a bit obvious but wouldn't printf work ?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Get an output of lines in pattern 1st line then 10th line then 11th line then 20th line and so on.

Input file: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 (6 Replies)
Discussion started by: Sagar Singh
6 Replies

2. Shell Programming and Scripting

Multi line log files to single line format

I want to read the log file which was generate from other command . And the output was having multi line in log files for job name and server name. But i need to make all the logs on one line Source file 07/15/2018 17:02:00 TRANSLOG_1700 Server0005_SQL ... (2 Replies)
Discussion started by: ranjancom2000
2 Replies

3. Shell Programming and Scripting

Format next line for ls output

hi i have 4 dir called old-dir1 old-dir2 dir3 dir4 now i need to grep only old dir named ls -d old* > outfileThe output will show as: cat outfile old-dir1 old-dir2Desired output is: old-dir1 old-dir2 (5 Replies)
Discussion started by: raghur77
5 Replies

4. Shell Programming and Scripting

Script to generate Excel file or to SQL output data to Excel format/tabular format

Hi , i am generating some data by firing sql query with connecting to the database by my solaris box. The below one should be the header line of my excel ,here its coming in separate row. TO_CHAR(C. CURR_EMP_NO ---------- --------------- LST_NM... (6 Replies)
Discussion started by: dani1234
6 Replies

5. Shell Programming and Scripting

Extract Line and Column from CSV Line in ksh or bash format

Hi, I was doing some research and can't seem to find anything. I'm trying to automate a process by creating a script to read a csv line and column and assigning that value to a variable for the script to process it. Also if you could tell me the line and column if it's on another work ... (3 Replies)
Discussion started by: vpundit
3 Replies

6. Shell Programming and Scripting

Modify a perl line to parse out and output to another format

Hey there... I am looking for a way to take the below contents ( small excerpt) of this file called PTR.csv ptrrecord,0000002e0cc0.homeoffice.anfcorp.com,,10.11.191.62,,,False,62.191.11.10.in-addr.arpa,,302400,default... (6 Replies)
Discussion started by: richsark
6 Replies

7. Shell Programming and Scripting

Dynamic output file generation using a input text file with predefined output format

Hi, I have two files , one file with data file with attributes that need to be sent to another file to generate a predefined format. Example: File.txt AP|{SSHA}VEEg42CNCghUnGhCVg== APVG3|{SSHA}XK|"password" AP3|{SSHA}XK|"This is test" .... etc --------- test.sh has... (1 Reply)
Discussion started by: hudson03051nh
1 Replies

8. Shell Programming and Scripting

capturing output from top and format output

Hi all, I'd like to capture the output from the 'top' command to monitor my CPU and Mem utilisation.Currently my command isecho date `top -b -n1 | grep -e Cpu -e Mem` I get the output in 3 separate lines.Tue Feb 24 15:00:03 Cpu(s): 3.4% us, 8.5% sy .. .. Mem: 1011480k total, 226928k used, ....... (4 Replies)
Discussion started by: new2ss
4 Replies

9. Shell Programming and Scripting

how to make a line BLINKING in output and also how to increase font size in output

how to make a line BLINKING in output and also how to increase font size in output suppose in run a.sh script inside echo "hello world " i want that this should blink in the output and also the font size of hello world should be big .. could you please help me out in this (3 Replies)
Discussion started by: mail2sant
3 Replies

10. UNIX for Dummies Questions & Answers

format output from while read line

I have an output that I get from while read, I want to display it as the following, please help. Original output from while read line loop: This is my client=1 client version=2.3.4 OS version=4.5 This is my client=2 client version=1.5.6 OS version=6.7 I want it to look like this with... (7 Replies)
Discussion started by: dala
7 Replies
Login or Register to Ask a Question