Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 01-30-2010, 04:44 AM   #1
Registered: Oct 2009
Posts: 40

Rep: Reputation: 15
SED - how to remove blank spaces

Hi all,

I'm having a problem trying to erase blank space between characters. I have the following in a file:

sc_signal< bool> inTicks_vl;
sc_signal< bool> inTicks_vr;
sc_signal< bool > inTicks_hl;
sc_signal< bool > inTicks_hr;

There I have normal spaces and tabs between the characters. So I tried to use:

sed -i 's/<\ *\([^ ]*\)\ *>\ *\([^ ]*\);/<\1>\2;/' file
sed -i 's/<\t *\([^ ]*\)\t *>\t *\([^ ]*\);/<\1>\2;/' file

So that my file would look like this (no spaces in between the words):


But the problem is that those commands just delete all tabs or all spaces until they find something else. That means, if in one line I have:


The result is:


Does somebody know a way to make it look like:

Word<Word>Word; at the end?
Old 01-30-2010, 05:32 AM   #2
Registered: Jan 2007
Location: Canton, MI
Distribution: CentOS, SuSE, Red Hat, Debian, etc.
Posts: 703

Rep: Reputation: 99
Try this: sed -i 's/[ Tab][ Tab]*//g' file

Obviously I can't type a tab character into a web form. Just
type a space and a tab between each of the square braces.
Old 01-30-2010, 06:02 AM   #3
Registered: Oct 2009
Posts: 40

Original Poster
Rep: Reputation: 15
Hi carltm!

many thanks for the solutions. It works


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
selectively remove blank spaces from string Cpt_Cell Linux - Newbie 2 10-08-2009 02:41 AM
to display the number of blank spaces in a specified file rajdey1 Linux - Newbie 10 11-25-2008 06:09 PM
How to add some spaces in sed command? reconcil Linux - Newbie 2 11-05-2007 11:00 AM
Inserting spaces using SED/AWK ? aravindts Programming 4 09-29-2006 05:28 AM
Problem with SED and blank spaces BigLarry Programming 2 06-10-2004 04:57 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:49 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration