ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
I found a command to display directory tree (see above), it didn't work correctly. It gave error message "Illegal variable name". I think the error is at $
sign. How can I modify this command for cshell environment?
-
1Other than escaping it?Ignacio Vazquez-Abrams– Ignacio Vazquez-Abrams2018年07月30日 08:04:02 +00:00Commented Jul 30, 2018 at 8:04
-
1I suspect that I am not the only one enjoying that the answer is given only a few characters further along in the question itself.JdeBP– JdeBP2018年07月30日 08:38:12 +00:00Commented Jul 30, 2018 at 8:38
-
What is "directory command"?ctrl-alt-delor– ctrl-alt-delor2018年07月30日 09:08:15 +00:00Commented Jul 30, 2018 at 9:08
2 Answers 2
:$
should be in single quotes to stop the shell from expanding it.
so ls -R | grep ':$' | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
Your next thing to learn, is shell quoting, and expansions.
Also a lot of people consider csh
to have been a mistake. It is full of odd inconsistent behaviour. Consider another bash
, ksh
, fish
...
Instead of a shell script you can use an external commands. 'tree' may be available in your environment, then it's easy.
tree -d