Link to home
Start Free TrialLog in
Avatar of Sigurdur Armannsson
Sigurdur ArmannssonFlag for Iceland

asked on

How do I to put a tab into text in a text file using Terminal on a mac

When I use Terminal to find every job that has been worked on last 24 hours I get a text file with lines like this:

ABC 12345 Job Worked on
DEF 67890 Another Job etc...

As this can be up to 50 lines and I need to put this into two columns in Excel I need to add a tab in every line, after the numbers.
Like this: ABC 12345 <tab> Job Worked on

What do the experts think is the best way to do this?
Avatar of MacFirst
MacFirst

I'd open it up in BBedit  and do a search and replace for
(\d+) and replace it with \1\t

That means find any single  number repeated and replace it with the found number followed by a tab.

You can do it with the  sed at the command line too

Avatar of Sigurdur Armannsson

ASKER

Ok. That's how I do that in Text Wrangler, BBedit's little brother. I have never used sed before. Let's give it a try. Same GREP or what?
man pages are not always that easy to learn by. Is it possible to get help with how I would implement this in sed?
ASKER CERTIFIED SOLUTION
Avatar of MacFirst
MacFirst

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks a lot. :D
This solution is what I was looking for. Besides being accurate it is explained well and will help me get started with using sed for future problems.