SCO 3.2v5.05Eb: ? on trimming strings


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers SCO 3.2v5.05Eb: ? on trimming strings
# 1  
Old 04-18-2002
Data SCO 3.2v5.05Eb: ? on trimming strings

Greetings.
If I have a file with the following format:

joe__________blow
1313 mockingbird pl.
Los Angeles________, CA. 90210


bill__________clinton
1234 doghouse
New York__________, NY. 12345


(note: I underlined what are spaces in the list due to the fact the billboard spaces them to 1 space)

How would I go about trimming the spaces between the words
down to 1 space?

I thought about sed, but the field delimiter is not fixed (a last name could have multiple parts for instances, and the space between first/last city/state is not a tab).

I am essentially looking for an ltrim/rtrim command for shell.

Thanks in advance.
gee-dub
# 2  
Old 04-18-2002
Try this:
Code:
echo "This is    a   weird            line,   yo" | sed 's/   */ /g'

In the sed statement, it's :
slash,space,space,space,star,slash,space,slash
(as if that makes more sense Smilie

It didn't seem to like "sed 's/ +/ /g'"
(space,space,plus)...
Anyone know why?
# 3  
Old 04-18-2002
Bug

that worked great. thanks alot 'livin free'.
gee-dub
# 4  
Old 04-18-2002
Quote:
Originally posted by LivinFree

It didn't seem to like "sed 's/ +/ /g'"
(space,space,plus)...
Anyone know why?
There are two kinds of regular expressions: basic regular expressions, and extended regular expressions. sed only uses basic regular expressions. The + sign is a feature of extended regular expressions.
# 5  
Old 04-19-2002
Ahh, I see now.
Thank you for the reply!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Trimming in between the words

Hi i have a log file P12345_15728710:DEBUG:Begin P12345_15728710:DEBUG:Being P12345_15729310:DEBUG:GetAgen P12345_15726510:DEBUG:end i want to trim this file and i want like this 15728710 15728710 15729310 15726510 i tried sed ..but not working.. sed "s/.*P12345__ \(.*\)... (4 Replies)
Discussion started by: navsan420
4 Replies

2. Shell Programming and Scripting

Trimming a string

Hi I need to trim white spaces from strings in a file. Input file is like this: 1_rrc_CatalogGroups.csv = 607 1_rrc_Sales_TopCatalogGroups.csv = 4 1_rrc_Sales_CatalogEntries_CatalogGroup_Rel.csv = 7 Need to trim space before and after = symbol. This is my script: #!/usr/bin/ksh ... (2 Replies)
Discussion started by: sukhdip
2 Replies

3. SCO

Printing to Windows 7 using Samba 2.0.3 via VPN connection to SCO 3.2v5.0.6

I would like to know if anyone has a way to PRINT TO a printer attached to a Windows 7 PC, from SCO, while logged in via a VPN connection. I am able to attach to a Samba share on the SCO server for files while attached to the VPN, so I know my Samba is workling - but my print jobs return: ... (2 Replies)
Discussion started by: tbb999
2 Replies

4. Shell Programming and Scripting

trimming sequences

My file looks like this: But I would like to 'trim' all sequences to the same lenght 32 characters, keeping intact all the identifier (>GHXCZCC01AJ8CJ) Would it be possible to use awk to perform this task? (2 Replies)
Discussion started by: Xterra
2 Replies

5. Shell Programming and Scripting

Trimming output

I'm trying to parse an output log and I've managed to reduce the output to the lines I need. But I'm having trouble pulling out only the info I'm interested in. The output is 40+ lines and here is a sample Installing AppFresh 0.8.5.pkg from ./InstallerFiles/CustomPKG/26 (26) Installing... (2 Replies)
Discussion started by: kaltekar
2 Replies

6. Shell Programming and Scripting

trimming lines

hi have output as i have trim of lines before CREATE statement and lins after last ")" any idea how to achieve it ? (3 Replies)
Discussion started by: crackthehit007
3 Replies

7. UNIX for Advanced & Expert Users

Trimming the spaces

Hi, How can I remove the unwanted spaces in the line. 123456 789 ABC DEF. - I wanna remove the sapces in this line, I need the output 123456789ABCDEF. Pls help me...... (3 Replies)
Discussion started by: sharif
3 Replies

8. UNIX for Advanced & Expert Users

trimming zeros

Hi, I want to trim +with leading zero's with amount fields.I know using awk for trimming leading zeros with +,but I want get the entire row itself. cat file_name |awk -F " " '{printf "%14.4f%f\n",$4}' ex: 10 xyz bc +00000234.4500 20 yzx foxic +002456.000 Expexted 10 xyz bc... (3 Replies)
Discussion started by: mohan705
3 Replies

9. Shell Programming and Scripting

Trimming a string

Hi, I am trying to find a script command that will let me trim leading and trailing space from a string. I have coded a SQL Select and sending the output to a file. Later I am parsing the file and reading each field. The problem is that each field uses the same size as the DB2 type it was defined... (2 Replies)
Discussion started by: fastgoon
2 Replies

10. UNIX for Dummies Questions & Answers

ulimit on sco release 3.2v5.0.4

How can the ulimit be increased from 2GB without changing the mounted file systems. (3 Replies)
Discussion started by: Shanker
3 Replies
Login or Register to Ask a Question