Hi,
I want to list all the directory and subdirectories under any directory.
For eg. i am in a directory called A and want to check all directories under A.
Output should be as below.
/A
/A/a1
/A/a1/a2
/A/b1
/A/c1/c2
A,a1,a2,b1,c1 and c2 all are directories.Just for Eg.
Please can any one help me to find me the O/P.
SysFe
February 20, 2010, 4:36pm
3
I used the following line of code in Ubuntu ksh, but it should also work on Solaris ksh:
find <your starting directory> -ls | grep " d" | tr -s [:space:] | cut -d " " -f11
I don't think any thing but the 'find' command is needed here.
Wow ..!! Thanks ..it worked ...
find ./ -type d --> exactly gave me the O/P what I wanted ..
second command gave me list of files also ...
if i want this through a script ...what will be my shell script..?any guidance. ..!!?
kshji
February 21, 2010, 3:17am
6
find is program, so you can call it almost from every interpreters like shells, perl, php, ... What you need ?
hey ..thanks ..!!
I have created one script.. Actually I am new in scripting.
below is my script
#!/bin/ksh
first_argument="$1"
second_argument="$2"
third_argument="$3"
find $1 -type d >> $2
scp -p -r $2 anshu@server1:/tmp/anshu/
Suppose .. $1 is my home directory and $2 is an O/P file.
$1= /home/anshu $2= /tmp/anshu.out
Now this script is working well and it is creating anshu.out on remote machine server1.
But now actually I want to create same directory structure om remote machine under path /tmp/anshu/ from script.
Could you please assist me.... what will be my I/P?
Modify to :
#!/bin/ksh
first_argument="$1"
second_argument="$2"
third_argument="$3"
find . -type d -exec echo mkdir -p {} \; >> $2
chmod 775 $2
scp -p -r $2 anshu@server1:/tmp/anshu/
ssh anshu@server1 "$2"