LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Simple Bash Script Help (http://www.linuxquestions.org/questions/programming-9/simple-bash-script-help-297899/)

njdownes 03-05-2005 07:09 AM

Simple Bash Script Help
 
Hi there.

I'm new to bash scripting and basically, I want to do the following and was wondering if someone could give me some pointers and show me the best way of doing it.

Basically, I want to poll a directory, let's call it /test and see if there are any files with the extension .dat, if there are any then I want them moved to another directory (/test2).
I want the script to loop until it finds these files, then move them and then once finished moving them, just carry on polling /test.

Any help with this would be greatly appreciated.

Thanks in advance.

ilikejam 03-05-2005 07:20 AM

Hi.

It would take longer to explain than it would to just write the script:
Code:

#!/bin/bash

cd /test
while true
  do
  mv *.dat /test2
  sleep 2
done

Dave

njdownes 03-05-2005 07:35 AM

Thanks!!!


All times are GMT -5. The time now is 10:32 AM.