![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| appending spaces to first line based on second record. | ammu | Shell Programming and Scripting | 2 | 11-16-2007 12:35 AM |
| splitting a record and adding a record to a file | rsolap | Shell Programming and Scripting | 1 | 08-13-2007 10:58 AM |
| Inserting spaces in a record | lyoncc | Shell Programming and Scripting | 5 | 06-01-2007 09:27 AM |
| adding spaces to a line | mgirinath | Shell Programming and Scripting | 4 | 03-23-2007 09:38 AM |
| adding a column at the end of the record | pavan_test | UNIX for Dummies Questions & Answers | 2 | 11-07-2005 08:39 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Adding spaces to record
Hi,
I want to print spaces in a trailer record which is a single command. namely the unix command which i already have recs=`wc -l $TargetFileDir/myfile.txt|cut -c1-9`;export recs;echo 'PCPC.DXDINPT.FC0.INPUTFLE.PASS'`date +%Y%m%d``printf '%015d\n' $recs` >> $TargetFileDir/myfile1.txt I wanted add a filler of say 200 spaces at the end. Is there any way by which i can do in same command |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Your printf statement should look like:
Code:
printf '%015d%-200s\n' $recs |
|
#3
|
|||
|
|||
|
Thanks a lot for your efforts and time.
Rather i tried with the printf arguments earlier but rather did not workout. I re-directed the output of the command to file and when i opened the file i could not see any spaces,even with se list option. recs=`wc -l PCPC.DXDINPT.FA0.INPUTFLE.PASS|cut -c1-9`;export recs;echo 'PCPC.DXDINPT.FA0.INPUTFLE.PASS'`date +%Y%m%d``printf '%015d%-200s\n' $recs` Output: PCPC.DXDINPT.FA0.INPUTFLE.PASS20080128000000000000101$ Where $ representing the end of line. Can you provide me some more suggestions |
|
#4
|
|||
|
|||
|
It works fine for me, try to give an extra space as follow:
Code:
printf '%015d%-200s\n' $recs ' ' Code:
recs=`wc -l PCPC.DXDINPT.FA0.INPUTFLE.PASS|cut -c1-9`;export recs;echo 'PCPC.DXDINPT.FA0.INPUTFLE.PASS'`date +%Y%m%d``printf '%015d%-200s\n' $recs ' '` |
|||
| Google The UNIX and Linux Forums |