Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I put tabs in text files from Terminal? [closed]

Tags:

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

ABC 12345 Job Worked on DATE

DEF 67890 Another Job on DATE

GHI 10112 Final Job on DATE

This text file can be up to hundred lines. I have to insert all this data into a tabel in Microsoft Excel. To make my life easier I would like to figure out how to add a tab in every line, after the numbers.

Something like this:

echo "ABC 12345 <tab> Job Worked on DATE" >> jobs.txt
echo "DEF 67890 <tab> Another Job on DATE" >> jobs.txt
echo "GHI 10112 <tab> Final Job on DATE" >> jobs.txt

How would I achieve this?

like image 237
W3Geek Avatar asked Jul 07 '12 20:07

W3Geek


2 Answers

Use echo -e with \t for a tab. Like this:

echo -e "ABC 12345 \t Job Worked on DATE" >> jobs.txt
like image 159
AW101 Avatar answered Nov 02 '22 03:11

AW101


You can press Ctrl-vTab to type a raw Tab.


You can also use $'...' c-string syntax:

echo $'ABC 12345 \t Job Worked on DATE' >> jobs.txt
like image 20
kev Avatar answered Nov 02 '22 05:11

kev