LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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
 
LinkBack 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: 96
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


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
Trackbacks are Off
Pingbacks are On
Refbacks are 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


All times are GMT -5. The time now is 12:52 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration