How to use t (tabulation) on EOF outputs?

Asked

Viewed 43 times

1

See the example below:

cat << EOF
alias\tVARIABLE = command
EOF

Execution output does not take regex into account \t.

1 answer

1


The cat does not interpret the escape codes but there are several ways to do it, one of them is to use the echo:

echo -e "alias\tVARIABLE = command"

That will return the sequence alias VARIABLE = command with the tab duly replaced.

Incidentally it is good to remember that by default the echo of Bash also does not interpret the escapes and needs the parameter "-e" and that this is unnecessary in the case of Dash.

But if you really need the operation to go through cat, can use process override:

cat <( echo -e "alias\tVARIABLE = command" )

That is, the exit from echo will be sent to the entry of cat as if it were an input file (such as the <<EOF ... EOF).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.