The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages 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 03:35 AM
splitting a record and adding a record to a file rsolap Shell Programming and Scripting 1 08-13-2007 01:58 PM
Inserting spaces in a record lyoncc Shell Programming and Scripting 5 06-01-2007 12:27 PM
adding spaces to a line mgirinath Shell Programming and Scripting 4 03-23-2007 12:38 PM
adding a column at the end of the record pavan_test UNIX for Dummies Questions & Answers 2 11-07-2005 11:39 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-25-2008
nvenkat010 nvenkat010 is offline
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
  #2 (permalink)  
Old 01-26-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,212
Your printf statement should look like:

Code:
printf '%015d%-200s\n' $recs
Regards
  #3 (permalink)  
Old 01-28-2008
nvenkat010 nvenkat010 is offline
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
  #4 (permalink)  
Old 01-28-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,212
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
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 07:47 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0