Sponsored Content
Full Discussion: directory tree
Top Forums Shell Programming and Scripting directory tree Post 302161222 by ravi raj kumar on Thursday 24th of January 2008 02:58:46 AM
Old 01-24-2008
directory tree

Hi all,
The following is a script for displaying directory tree.

D=${1:-`pwd`}
(cd $D; pwd)
find $D -type d -print | sort |
sed -e "s,^$D,,"\
-e "/^$/d"\
-e "s,[^/]*/\([^/]*\)$,\:-----\1,"\
-e "s,[^/]*/,: ,g" | more
exit 0

I am trying to understand the above script.But i am not able to understand the following 2 lines

-e "s,[^/]*/\([^/]*\)$,\:-----\1,"\
-e "s,[^/]*/,: ,g" | more

can any body pls tell me how the above two lines works.

cheers
RRK
 

10 More Discussions You Might Find Interesting

1. Programming

Directory tree search???

Hi all, I've got a problem, what function do i use to list the contents of all the directory tree (simular to "find")? Any other suggestions? Thank you all (3 Replies)
Discussion started by: solvman
3 Replies

2. Programming

directory as tree

hi i have modified a program to display directory entries recursively in a tree like form i need an output with the following guidelines: the prog displays the contents of the directory the directory contents are sorted before printing so that directories come before regular files if an entry... (2 Replies)
Discussion started by: anything2
2 Replies

3. Shell Programming and Scripting

Searching directory tree

I'm currently trying to write a script that will do the following: search a given directory tree for a file with MMDDYYYY in the name. delete those files only. I can't figure out how to make the script delete the files with the MMDDYYYY in the filename after finding them. Should I export... (7 Replies)
Discussion started by: blane
7 Replies

4. Shell Programming and Scripting

setup directory tree

All, I am new to Unix scripting ans was looking for some guidance. I basically have to: 1. Check if a directory exists - if not create it 2. Check the permissions of the dir - if Wrong change loop this. Sort of creating a directory tree. Thanks. (2 Replies)
Discussion started by: wicked24
2 Replies

5. UNIX for Dummies Questions & Answers

Protecting the directory tree

Hello, I am hoping someone maybe able to help me. I have set up an Apache web server on my sun server with user accounts in the main htdocs directory. My question is how to stop these users searching up the directory tree when they ftp/telnet to the server. Also is it possible to restrict the... (2 Replies)
Discussion started by: rooneyl
2 Replies

6. UNIX for Dummies Questions & Answers

Move all files in a directory tree to a signal directory?

Is this possible? Let me know If I need specify further on what I am trying to do- I just want to spare you the boring details of my personal file management. Thanks in advance- Brian- (2 Replies)
Discussion started by: briandanielz
2 Replies

7. Shell Programming and Scripting

creating a directory tree

Hi all, I'd like to create a directory tree, and define from stdin how many levels deep and how many directories in each level should be created. What I wrote does not work properly:#!/bin/bash #set -x read -p " What root directory? " rootDir && { /bin/rm -R $rootDir; mkdir $rootDir; } ||... (2 Replies)
Discussion started by: NBaH
2 Replies

8. UNIX for Dummies Questions & Answers

directory tree with directory size

find . -type d -print 2>/dev/null|awk '!/\.$/ {for (i=1;i<NF;i++){d=length($i);if ( d < 5 && i != 1 )d=5;printf("%"d"s","|")}print "---"$NF}' FS='/' Can someone explain how this works..?? How can i add directory size to be listed in the above command's output..?? (1 Reply)
Discussion started by: vikram3.r
1 Replies

9. UNIX for Dummies Questions & Answers

How to copy a tree of directory

Mi question is how can you copy only de three of directory and not the files in it. Only a need the three of directorys not the files (6 Replies)
Discussion started by: enkei17
6 Replies

10. Shell Programming and Scripting

Specific directory parsing in a directory tree

Hi friends, Hello again :) i got stuck in problem. Is there any way to get a special directory from directory tree? Here is my problm.." Suppose i have one fix directory structure "/abc/xyz/pqr/"(this will be fix).Under this directory structure i have some other directory and... (6 Replies)
Discussion started by: harpal singh
6 Replies
PWD(1)							    BSD General Commands Manual 						    PWD(1)

NAME
pwd -- return working directory name SYNOPSIS
pwd [-L | -P] DESCRIPTION
The pwd utility writes the absolute pathname of the current working directory to the standard output. Some shells may provide a builtin pwd command which is similar or identical to this utility. Consult the builtin(1) manual page. The options are as follows: -L Display the logical current working directory. -P Display the physical current working directory (all symbolic links resolved). If no options are specified, the -P option is assumed. ENVIRONMENT
Environment variables used by pwd: PWD Logical current working directory. EXIT STATUS
The pwd utility exits 0 on success, and >0 if an error occurs. SEE ALSO
builtin(1), cd(1), csh(1), sh(1), getcwd(3) STANDARDS
The pwd utility conforms to IEEE Std 1003.1-2001 (``POSIX.1''). BUGS
In csh(1) the command dirs is always faster because it is built into that shell. However, it can give a different answer in the rare case that the current directory or a containing directory was moved after the shell descended into it. The -L option does not work unless the PWD environment variable is exported by the shell. BSD
April 12, 2003 BSD
All times are GMT -4. The time now is 09:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy