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

Sigurdur Armannsson
Sigurdur Armannsson used Ask the Experts™
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?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

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

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?
How to Generate Services Revenue the Easiest Way

This Tuesday! Learn key insights about modern cyber protection services & gain practical strategies to skyrocket business:

- What it takes to build a cloud service portfolio
- How to determine which services will help your unique business grow
- Various use-cases and examples

I used z shell to make tab work. use the actual tab key.

At the command prompt, type:

sed 's/[0-9][0-9]* /&  /' <text >text2

where text is the name of your file and text 2 is the target file.

The & stands for the found expression (the numbers) and right after that is the tab key. Copy and paste from here or copy your own "tab"  if you need to.

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.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial