LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 11-11-2004, 01:08 PM   #1
RowanB
LQ Newbie
 
Registered: Nov 2004
Posts: 8

Rep: Reputation: 0
Does anyone know how to move files to a particular directory using shell scripting


Can anyone write a script that moves all the files that end in ".txt" from the current directory to another (target) directory. The target directory should be identified via a parameter passed to the script. This script should also produce a text file ("filesCopied") that lists all files that have been moved.
 
Old 11-11-2004, 01:23 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
How about:

Code:
#!/bin/bash
mv -v *.txt $1
 
Old 11-11-2004, 01:27 PM   #3
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
We generally don't people's homework, but we may help help if you're stuck and post the code.

(see the rules of this forum )
 
Old 11-11-2004, 01:46 PM   #4
RowanB
LQ Newbie
 
Registered: Nov 2004
Posts: 8

Original Poster
Rep: Reputation: 0
Quote:
Originally posted by Hko
We generally don't people's homework, but we may help help if you're stuck and post the code.

(see the rules of this forum )
Sorry, I shouldn't have posted the whole question. I really just wanted to know how to move files to get me started. It's only one question in a much bigger assignment anyway.
 
  


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
Shell Scripting and Files With Spaces Matir Programming 12 08-17-2005 01:43 AM
shell scripting full directory listing sqn Programming 4 04-13-2005 04:33 PM
how to write a script to move files from one directory to another myeire Linux - Newbie 7 02-25-2005 10:01 AM
shell scripting: checking for modified files topcat Linux - General 4 12-08-2004 04:43 AM
how do I move a directory in shell DKY Linux - Newbie 7 07-30-2003 05:33 PM

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

All times are GMT -5. The time now is 12:17 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