I want to make an alias tree with find ./ -type d -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g' as its value.

so to avoid mistakes due to ' inside whole line I converted them to \' by which I can define it's scope. so my actual command looks like this:

alias tree='find ./ -type d -print | sed -e \'s;[^/]*/;|____;g;s;____|; |;g\''

but it shows error

bash: syntax error near unexpected token `|'

but I don't know how to fix this issue.

1 Answer 1


I got the answer I tried some random hits and the solution is...

alias tree="find ./ -type d -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"

By using double quotes " .

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .