LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-05-2005, 07:09 AM   #1
njdownes
LQ Newbie
 
Registered: Feb 2005
Posts: 10

Rep: Reputation: 0
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.
 
Old 03-05-2005, 07:20 AM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
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
 
Old 03-05-2005, 07:35 AM   #3
njdownes
LQ Newbie
 
Registered: Feb 2005
Posts: 10

Original Poster
Rep: Reputation: 0
Thanks!!!
 
  


Reply



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
Simple bash script lp449 Linux - Networking 3 08-02-2005 04:25 PM
Simple bash script Soulful93 Programming 1 06-04-2005 07:26 PM
Simple Bash Script dmedici Programming 9 12-31-2004 03:48 AM
Help with simple bash script - please tw001_tw Linux - Software 5 12-19-2004 09:02 PM
Simple BASH script fio Linux - General 5 01-18-2003 03:26 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:24 PM.

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