Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have data of the following format that I want to input into LibreOffice Calc:

data | num | num | num | num

For some reason LibreOffice does not think the string "3214 " is a number by default (trailing white space).

I want to replace (\s)*| with |, where \s stands for space and * for the Kleene star operation. And do this at multiple places in each line (all matches).

I tried:

sed -i 's/(\s)*|/|/' DataStats0914.txt

But it has no effect. What am I doing wrong?

share|improve this question
    
Is another way to phrase this to just delete all whitespace? In that case, just a comment on the right tool for the right job: tr -d ' ' < DataStats0914.txt > DataStats0914.txt.modified. –  Daniel Andersson Oct 22 '12 at 9:00
add comment

1 Answer

up vote 0 down vote accepted

This will do it.

sed 's/ *|/|/g'
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.