Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing leading space in a file

Status
Not open for further replies.

UCF87

Technical User
Feb 13, 2003
44
0
0
US
Need a way to remove the space before 0444 and 0068(bottom) without affecting other data in the file. I have about 730 numbers in this file that I need to remove the leading space. Thanks in advance.

Sample data:

dscoggi CAPVBRET 55 55 Transfer output file VENBAL to 2
APVENBAL1
0444
0 0

dscoggi CAPVMTEST 0 0 Apcvenmast File Export 0
LC834 LIFECARR LIFECARR
PRT1006800000000
0 0

dscoggi CAPVMTEST 1 1 Transfer output file VENDMAST 2
APVENMAST1
0068
 
Try Trim([Fieldname]) It will strip out the extra spaces.

My concern is the format of the data if it is parsed into the proper field assignment then the Trim function will work.

HTH,

Steve
 
How can you recognize this 730 numbers ? Fixed position within record ? Allways at beginning of a line ?
Something like this ?
sed -e 's!^ \([0-9]\)!\1!' /path/to/input >output

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
What application uses trim? Forget to mention I am on AIX 5.1.
 
UCF87,

Apologies. The other option is you can apply the tr command to do a squeeze. I was thinking DB applications.


tr -s '<tab><space>' '<space><space>' /input path/ > output


Steve
 
well shoot, I have tried every tr and sed sequence I can think of and still can not remove the space. Thanks for your help anyway.
 
Dump your file (man od) to figure out which character is this unwanted "space".

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
sed "s/^0/0/g" file > newfile

This works... I was making this too complicated. Other zeros are moved but does not corrupt the file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top