The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
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

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 01-25-2008
Registered User
 

Join Date: Jan 2008
Posts: 3
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
Reply With Quote
Forum Sponsor
  #2  
Old 01-26-2008
Moderator
 

Join Date: Feb 2007
Posts: 2,199
Your printf statement should look like:

Code:
printf '%015d%-200s\n' $recs
Regards
Reply With Quote
  #3  
Old 01-28-2008
Registered User
 

Join Date: Jan 2008
Posts: 3
Question

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
Reply With Quote
  #4  
Old 01-28-2008
Moderator
 

Join Date: Feb 2007
Posts: 2,199
It works fine for me, try to give an extra space as follow:

Code:
printf '%015d%-200s\n' $recs ' '
so your command should look like:

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 ' '`
Regards
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 04:16 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0