Adding spaces to record


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Adding spaces to record
# 1  
Old 01-25-2008
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  
Old 01-26-2008
Your printf statement should look like:

Code:
printf '%015d%-200s\n' $recs

Regards
# 3  
Old 01-28-2008
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  
Old 01-28-2008
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Adding end of line character in the last record

Need to add end of line character to last record in a fixed width file. When i take the record length of each line, for all the records it gives example like 200 except the last line as 199. Due to this my other script fails. Please help me on this. (4 Replies)
Discussion started by: Amrutha24
4 Replies

2. Shell Programming and Scripting

Removing spaces from record

HI i have record as shown below 402665,4X75,754X_FERNIE BC,12F2,008708,FERNIE BC,1,UTC ,UTC ,250 402665,4X75,754X_FERNIE BC,F212,008708,FERNIE BC,1,UTC ,UTC ,250 402665,4Y75,754Y_FERNIE BC,22F2,008708,FERNIE BC,1,UTC ,UTC ,250 here i want to remove multiple spaces into no... (3 Replies)
Discussion started by: raghavendra.cse
3 Replies

3. Shell Programming and Scripting

how to add blank spaces at the end of every record in a file.

hi, Does anyone has any idea in adding few blank spaces at the end of every record in a file. Eg: file.txt Baby Boy Kim 1234 Baby Boy Vik 1334 Desired output:- output.txt Baby Boy Kim 1234 Baby Boy Vik 1334 I want to add 10 blank spaces at the end every record in file.txt (3 Replies)
Discussion started by: techmoris
3 Replies

4. Shell Programming and Scripting

Help with awk adding spaces.

I have a file that contains... elm,mail elm,lisp,composer,cd,ls,cd,ls,cd,ls,zcat,|,tar,-xvf,ls,cd,ls,cd,ls,vi,ls,cd,ls,vi,elm,-f,ls,rm,ls,cd,ls,vi,vi,ls,vi,ls,cd,ls,elm,cd,ls,cd,ls,vi,vi,vi,ls,vi,ls,i,vi,ls,cp,cd,fg,ls,rm,cd,ls,-l,exit elm,mail,biff,elm,biff,elm,elm elm,ls ... (2 Replies)
Discussion started by: Bandit390
2 Replies

5. Shell Programming and Scripting

adding spaces for a variable value

Hi, i have to form the header and add fillers(spaces) to it. I have done something like this. i have added 10 spaces at the end HDR="AAAABBBBCCNN " echo $HDR >> file1.dat but the spaces are not being stored in the file. How to add the spaces. (2 Replies)
Discussion started by: dnat
2 Replies

6. Shell Programming and Scripting

appending spaces to first line based on second record.

Hi, I have a situation to append spaces to end of first record (header)and last record (footer) based on second record length. The first record length is always 20.The second record will be different for different files.I have to append spaces for the first line based on second record... (2 Replies)
Discussion started by: ammu
2 Replies

7. Shell Programming and Scripting

splitting a record and adding a record to a file

Hi, I am new to UNIX scripting and woiuld appreicate your help... Input file contains only one (but long) record: aaaaabbbbbcccccddddd..... Desired file: NEW RECORD #new record (hardcoded) added as first record - its length is irrelevant# aaaaa bbbbb ccccc ddddd ... ... ... (1 Reply)
Discussion started by: rsolap
1 Replies

8. Shell Programming and Scripting

Inserting spaces in a record

Hi all. I am using /bin/sh on an HPUX system. I have a file, with records as such: 60701006000000030380000000000000030380000400000000000 61001006000000008220000000000000008220000100000000000 61201006000000030150000000000000030150001000000000000 I know the character counts which... (5 Replies)
Discussion started by: lyoncc
5 Replies

9. Shell Programming and Scripting

adding spaces to a line

Is there any command to add spaces to a lline....say i need 50 spaces between the data like "aaabbbccc dddeeefff" or may be like this "aaaabbbbbbcccccdddddeeeffff " your help is appreciated. (4 Replies)
Discussion started by: mgirinath
4 Replies

10. UNIX for Dummies Questions & Answers

adding a column at the end of the record

hello., i have a .txt file. inside the .txt file i have., /home/ss/cca.costco.transaction_date /home/sk/cca.costco.transaction_date /home/st/cca.costco.transaction_date /home/sv/cca.costco.transaction_date cca.costco.transaction_date is the file name. inside the file there are some... (2 Replies)
Discussion started by: pavan_test
2 Replies
Login or Register to Ask a Question