i want to create a folder with the name "NEW" in all the dirs & subdirs under /home/user/Project_Src and perform action (rm -rf .svn) in above mentioned directories.(ie under Project_Src all dirs & subdirs) while performing action i want the directory name in which the action is performed ie echo $dirname.
Result should be with the removal of .svn in all dirs,subdirs recursively:
/home/user/Project_Src/NEW
/home/user/Project_Src/Dir_A/NEW
/home/user/Project_Src/Dir_A/subdir/sub_dir2/NEW
/home/user/Project_Src/Dir_A/subdir/sub_dir3/NEW
/home/user/Project_Src/Dir_B/NEW
/home/user/Project_Src/Dir_B/Build/NEW
...
Something like this ?
Code:
$
$
$ # show the entire file hierarchy from the root directory "Project_Src"
$ find ./Project_Src -name "*"
./Project_Src
./Project_Src/x1.svn
./Project_Src/Dir_B
./Project_Src/Dir_B/x1.svn
./Project_Src/Dir_B/Build
./Project_Src/Dir_B/Build/x1.svn
./Project_Src/Dir_B/Build/y1.txt
./Project_Src/Dir_B/y1.txt
./Project_Src/Dir_A
./Project_Src/Dir_A/x1.svn
./Project_Src/Dir_A/y1.txt
./Project_Src/Dir_A/subdir
./Project_Src/Dir_A/subdir/sub_dir2
./Project_Src/Dir_A/subdir/sub_dir2/x1.svn
./Project_Src/Dir_A/subdir/sub_dir2/y1.txt
./Project_Src/Dir_A/subdir/sub_dir3
./Project_Src/Dir_A/subdir/sub_dir3/x1.svn
./Project_Src/Dir_A/subdir/sub_dir3/y1.txt
./Project_Src/Dir_A/subdir/x1.svn
./Project_Src/Dir_A/subdir/y1.txt
./Project_Src/y1.txt
$
$ # show the content of the Bash shell script that processes
$ # all directories in "Project_Src" recursively
$ cat -n processdirs.sh
1 #!/bin/bash
2 for i in `find ./Project_Src -type d -name "*"` ; do
3 echo "Now inspecting directory : $i"
4 echo "Now removing svn files..."
5 rm $i/*.svn
6 echo "Now creating directory NEW..."
7 mkdir -p $i/NEW
8 echo "=========================================================================="
9 done
$
$
$ # now execute the script "processdirs.sh"
$ ./processdirs.sh
Now inspecting directory : ./Project_Src
Now removing svn files...
Now creating directory NEW...
==========================================================================
Now inspecting directory : ./Project_Src/Dir_B
Now removing svn files...
Now creating directory NEW...
==========================================================================
Now inspecting directory : ./Project_Src/Dir_B/Build
Now removing svn files...
Now creating directory NEW...
==========================================================================
Now inspecting directory : ./Project_Src/Dir_A
Now removing svn files...
Now creating directory NEW...
==========================================================================
Now inspecting directory : ./Project_Src/Dir_A/subdir
Now removing svn files...
Now creating directory NEW...
==========================================================================
Now inspecting directory : ./Project_Src/Dir_A/subdir/sub_dir2
Now removing svn files...
Now creating directory NEW...
==========================================================================
Now inspecting directory : ./Project_Src/Dir_A/subdir/sub_dir3
Now removing svn files...
Now creating directory NEW...
==========================================================================
$
$
$ # check the entire hierarchy tree again, to ensure that the script worked
$ find ./Project_Src -name "*"
./Project_Src
./Project_Src/Dir_B
./Project_Src/Dir_B/Build
./Project_Src/Dir_B/Build/NEW
./Project_Src/Dir_B/Build/y1.txt
./Project_Src/Dir_B/NEW
./Project_Src/Dir_B/y1.txt
./Project_Src/NEW
./Project_Src/Dir_A
./Project_Src/Dir_A/NEW
./Project_Src/Dir_A/y1.txt
./Project_Src/Dir_A/subdir
./Project_Src/Dir_A/subdir/sub_dir2
./Project_Src/Dir_A/subdir/sub_dir2/NEW
./Project_Src/Dir_A/subdir/sub_dir2/y1.txt
./Project_Src/Dir_A/subdir/sub_dir3
./Project_Src/Dir_A/subdir/sub_dir3/NEW
./Project_Src/Dir_A/subdir/sub_dir3/y1.txt
./Project_Src/Dir_A/subdir/NEW
./Project_Src/Dir_A/subdir/y1.txt
./Project_Src/y1.txt
$
$
tyler_durden
This User Gave Thanks to durden_tyler For This Post:
Hello,
I have a script that monitors files uploaded via ftp. After a successful upload, the file name is written to the pipe.
There is another program that reads this pipe and allows automatically run any program or script ( say test.sh ) to process the newly uploaded file.
cat test.sh... (2 Replies)
Greetings!
I have multiple files, one per subdirectory, all with the same file name. All subdirectories are one level deep from the main directory.
The data in the files is tab delimited between fields and record delimited with a newline.
The subdirectory names have the date in the... (5 Replies)
I have 2 files. I basically want to search both of them to see if the 1st column ($1) matches and if it matches then check to see if the 2nd column ($2) matches, then execute some code showing the results of the matches.
File 1:
AAA 123
misc blah
BBB 456
CCC 789
File 2:
... (2 Replies)
I don't quite know what I'm doing, so this simple script is proving a challenge.
Here is some pseudo code that doesn't work yet:
if tail -1 "WORKING.txt" >/dev/null | egrep "^NMBR=*" > /dev/null
then
curl -k 'http://www.myserver.com/log.cgi?input=$?'
echo "hi there"
fi
Purpose:... (3 Replies)
Hi,
I want to run git status for the dir which has subdir ".git" in it with dir path mentioned in output log?
If a dir does not have .git subdir then skip that dir.
Dir will have 100 main dirs & 500 + subdirs and so on.
I appreciate all your help :b: (4 Replies)
hi,
i have a service on unix platform, it will generate traces in a particular folder
i want to check using shell script if traces exist, then perform some action else continue to be in loop.
filename is service.tra
can you please help?
thanks (4 Replies)
Hello Comunity
I am trying to make a bash shell script that it copies files and subdirs(with files) to a new dir. I would like the dest_dir to contain only subdirectories with files not other subdirs inside.
it called : cpflatdir src_dir dest_dir
Pleaze help me!
Thank you in... (2 Replies)
du -hs command calculates the space for all the subdirs under a dir ...but it is very slow if the dir is huge....is there any quick way ...I am using Sun OS.
Thanks,
Ajay (19 Replies)
Hi,
I would like to list all files, older than 7 days, in a directory, but exclude all subdirectories in the find command. If I use find . -type f -mtime +7 all files in the subdirs are also included. How can I exclude them?
Regards,
JW (6 Replies)
Hello,
I'm attempting to write a tool that checks an IP address for existing PTR records then if there are no PTR records does a ping to see if it response.
Then if there is no response, it should print a message saying
This is what I have so far.
#!/usr/bin/perl
$nxdomain =... (4 Replies)