android_su
android_su

Reputation: 1687

How can I concat two strings with tab in bash?

There's a snippet code here.

$ a=aa
$ b=bb
$ echo -e $a"\t"$b
aa       bb
$ c=`echo -e $a"\t"$b`
$ echo $c
aa bb
$ echo -e $c
aa bb

I wanna concat the $a and $b with tab, and set the result to variable c for a further use.

But When I echo $c, no tab display, only a space.

What should I do?

Upvotes: 1

Views: 7622

Answers (1)

sat
sat

Reputation: 14949

Try this:

echo "$c"

You need to quote the variable. Moreover, since you already interpreted the escape sequence during the assignment to c, you don't need to specify -e while echoing the value.

Upvotes: 4

Related Questions