Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 10-25-2011, 03:45 PM   #1
LQ Newbie
Registered: Oct 2011
Posts: 5

Rep: Reputation: Disabled
Unhappy bash - execute on each directory within a directory

Hello all,
I need some help writing a bash script.

I need to execute a svn-dump on each directory within my svn-directory and then name the dumpfile whatever the directory was called with ".dump" as the extension.

Here is what I have so far:



for file in $( ls $directory )
svnadmin dump $directory > $rename
Within the /var/svn directory I have about 50 svn repositories such as /var/svn/IT.

You can probably tell I have no idea what I'm doing a little help would go a long way. =)
Old 10-25-2011, 05:55 PM   #2
Julian Andrews
LQ Newbie
Registered: Jan 2011
Distribution: Ubuntu
Posts: 21

Rep: Reputation: 13
Your script seems pretty close to the mark to me!

A couple minor notes:

It's best to avoid using 'ls' when you can just use globbing - it's faster and easier to read.

Also, you should always use quotes around filenames in case they have spaces in them.

You can check if a file is a directory with the if [ -d "$file" ] construct.

Working on the assumption that you want the .dump files in the /var/svn folder, here's what I came up with.


for file in "$directory"/*
    if [ -d "$file" ]
        svnadmin dump "$file" > "$file$extension"
Let me know if this works for you!
1 members found this post helpful.
Old 10-25-2011, 06:10 PM   #3
Registered: Aug 2007
Posts: 133

Rep: Reputation: 16
Also, have a look at It takes care of backing up and rotating/archiving...
1 members found this post helpful.
Old 10-26-2011, 12:02 PM   #4
LQ Newbie
Registered: Oct 2011
Posts: 5

Original Poster
Rep: Reputation: Disabled
Thanks Julian! That worked great. Glad to know I was kinda close myself =P

I will look into spankbot. Thanks.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] su results in Cannot execute bash: No such file or directory gujedan Linux - Newbie 1 02-13-2011 01:24 PM
Directory execute permission MTK358 Linux - Newbie 2 04-24-2010 10:53 PM
Bash scripting: "line [...]: [directory]: is a directory " ? serious Linux - Newbie 1 10-20-2007 12:08 PM
Execute command from other users directory ruj.sabya Linux - General 1 05-25-2007 08:01 AM
Bash script to strip a certain directory out of directories in a directory? rylan76 Linux - General 3 08-29-2006 11:35 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:25 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration