PDA

View Full Version : Bash Script programing



sudansh
January 23rd, 2009, 08:33 AM
Hi, I am new to writing bash script file. I want to write a script to print the directory structure of a folder.(as in command "TREE" in DOS). But without the use of "ls" or "find" command.
Can anyone help me in this.
And yes i m in a college ..and this is my assignment so i CAN'T use ls or find command.

Tony Flury
January 23rd, 2009, 08:45 AM
As a matter of interest - why don't you want to use the ls command (which after all is there to list the contents of a folder and could easily form the basis of what you want to do).

It seems like an very arbitary restriction that could well make life very difficult for you.

In fact it sounds like the sort of restriction placed on students in coursework in order to ensure that they explore all the system capabilities (rather than solving the problem in the most obvious way).

eightmillion
January 23rd, 2009, 08:50 AM
Hi, I am new to writing bash script file. I want to write a script to print the directory structure of a folder.(as in command "TREE" in DOS). But without the use of "ls" command.
Can anyone help me in this.

sudo aptitude install tree

Cracauer
January 23rd, 2009, 04:56 PM
`du -a`

kaibob
January 23rd, 2009, 07:40 PM
I'm not familiar with tree but...


find -type d

or


find /directory/name -type d

The second of the above gives the full path.

Martin Witte
January 23rd, 2009, 10:19 PM
well, with ls:

ls -aR
or

ls -alR