Personal computing discussed

Moderators: renee, SecretSquirrel, notfred

 
flip-mode
Grand Admiral Gerbil
Topic Author
Posts: 10218
Joined: Thu May 08, 2003 12:42 pm

sed script - remove tabs at begin of line

Tue Apr 21, 2009 8:47 pm

Alright gurus, I am trying to remove tab spaces from the beginnings of lines in a file. Here's how I'm trying to do it:

sed -e '/^\t*/d' infile > outfile

It results in an empty output file. What am I screwing up?
 
bitvector
Grand Gerbil Poohbah
Posts: 3293
Joined: Wed Jun 22, 2005 4:39 pm
Location: San Francisco, CA

Re: sed script - remove tabs at begin of line

Tue Apr 21, 2009 8:57 pm

You're deleting all of those lines that match the expression "^\t*" -- a line beginning with 0 or more tabs.

I'd do:
sed -e 's/^\t*//' (substitute the leading tab(s) with nothing)
 
flip-mode
Grand Admiral Gerbil
Topic Author
Posts: 10218
Joined: Thu May 08, 2003 12:42 pm

Re: sed script - remove tabs at begin of line

Tue Apr 21, 2009 9:00 pm

LOL. Thanks BV.
 
flip-mode
Grand Admiral Gerbil
Topic Author
Posts: 10218
Joined: Thu May 08, 2003 12:42 pm

Re: sed script - remove tabs at begin of line

Tue Apr 21, 2009 9:01 pm

Heh, yep, that did the trick.

Who is online

Users browsing this forum: No registered users and 1 guest
GZIP: On