1

I am creating a Loop that will let me rsync files from a variable directory one level above and then bzip those files at every level, infinitely until I press CTRL+C. So far this is what I have for the shell script:

while :

do

        rsync -av ../gene/ .
        bzip2 -kv */*/*/*/*/*/*/*
        bzip2 -kv */*/*/*/*/*/*
        bzip2 -kv */*/*/*/*/*
        bzip2 -kv */*/*/*/*
        bzip2 -kv */*/*/*
        bzip2 -kv */*/*
        bzip2 -kv */*
        echo "Press [CTRL+C] to stop.."
        sleep 1
done

What I would like to have happen is it ask for the directory that it should rsync from. The directory is not always gene and is variable, so user input is a must. Any help with this and possibly cleaning the script up is much appreciated.

1 Answer 1

1

You could do this:

#!/bin/bash

myFolder=$1;

echo "Working on "$myFolder;

while :

do

        rsync -av $myFolder .
        bzip2 -kv */*/*/*/*/*/*/*
        bzip2 -kv */*/*/*/*/*/*
        bzip2 -kv */*/*/*/*/*
        bzip2 -kv */*/*/*/*
        bzip2 -kv */*/*/*
        bzip2 -kv */*/*
        bzip2 -kv */*
        echo "Press [CTRL+C] to stop.."
        sleep 1
done

save with the name someprogram.sh and excute (if you are there)

bash ./someprogram.sh someFolder
Sign up to request clarification or add additional context in comments.

2 Comments

Exactly what I was looking for. Thanks so much!
If I run this from the folder I want to rsync information to it is looking at /currentFolder/someFolder. Is there any way to get it to rsync from one level above on someFolder?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.