01-22-2009
Moving file(s) from dir to dir
Hi, I am fairly new to writing scripts.
I am trying to write a script that moves either One or All of the files from one directory to another.
I know how to make the actual command to do it, but i don't quite know how to add operators to it, ie -i or -a.
I want -i to move one file from the directory, asking the user to confirm if he/she wants to move this file or not.
And -a to move all the files to the other directory.
I would really appreciate any help that anyone can give me.
Thanks
Joeh.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
hi all,
i'm looking for a bash or tcsh script that will clone an empty dir tree 'over' another tree ...
specifically, i'd like to:
(1) specify a src directory
(2) list the directory tree/hiearchy beneath that src dir, w/o files -- just the dirs
(3) clone that same, empty dir hierarchy to... (2 Replies)
Discussion started by: OpenMacNews
2 Replies
2. Shell Programming and Scripting
hi
i have a script
compareFiles()
{
find /tmp/Satya -type f | \
while read filename1
do
echo "----------------------------------------$filename1"
find /tmp/Satya -type f | \
while read filename2
do
if diff $filename1 $filename2
then
echo "Both files... (3 Replies)
Discussion started by: Satyak
3 Replies
3. Shell Programming and Scripting
I have created a directory structure and under the directory subdirectories and files are there.I need to move the entire thing
to another path.How can i write a script to do that.
currently the path of files is as below :
/data1/serial/mcycle/archive : under this path differnt sub dir exist ... (6 Replies)
Discussion started by: dr46014
6 Replies
4. Shell Programming and Scripting
Hi,
I want to Move files from one dir to another dir on same mount point.
The source dir may contain subdir or files within it.
Search the files or subfolder which is older then a given datetime .
Move the file recursively and after each successful move of file make an entry to log... (2 Replies)
Discussion started by: rkmbcbs
2 Replies
5. UNIX for Dummies Questions & Answers
Hey all,
i want to copy only the file names from an ftp server (directory and all sub directory) to a text file in another server (non ftp), i.e. i want to recursively move through directories and copy only the names to a text file.
any help is appreciated...thank you in advance (1 Reply)
Discussion started by: deking
1 Replies
6. Shell Programming and Scripting
Hi, I am a unix newbie.I need to write a shell script to move my oracle READ WRITE datafiles from one serevr to another. I need to move it from /u01/oradata/W1KK/.. to /u01/oradata/W2KK,
/u02/oradata/W1KK/.. to /u02/oradata/W2KK.
That is, I actaully am moving my datafiles from one database to... (2 Replies)
Discussion started by: mathews
2 Replies
7. UNIX for Dummies Questions & Answers
I am very new to unix as well as shell scripting.
I have to write a script for the following requirement. In have to list all the files in directory and its sub directories along with file path and size of the file
Please help me in this regard and many thanks in advance. (3 Replies)
Discussion started by: nmakkena
3 Replies
8. Shell Programming and Scripting
Hi frnds
The following is the code
#!/bin/ksh
##############################################################
# #
# Created by eDB Dev - 27-May-2011 #
# ... (1 Reply)
Discussion started by: balesh
1 Replies
9. Shell Programming and Scripting
Hi Guys ,
I want create files Dire and Sub Dire. as same time using variable.
EX:
x1="/hk/Pt/put/NC/R1.txt"
x2="/hk/pt/Put/Ot/NC/RN.txt"
And i want delete all after done with my script.
Thanks (2 Replies)
Discussion started by: pareshkp
2 Replies
10. AIX
I have searched this quite a long time but couldn't find the right method for me to use. I need to assign read write permission to the user for specific directories and it's sub directories and files. I do not want to use ACL. I do not want to assign user the same group of that directories too.... (0 Replies)
Discussion started by: blinkingdan
0 Replies
mv(1) General Commands Manual mv(1)
Name
mv - move or rename files
Syntax
mv [-i] [-f] [-] file1 file2
mv [-i] [-f] [-] file... directory
Description
The command moves (changes the name of) file1 to file2.
If file2 already exists, it is removed before file1 is moved. If file2 has a mode which forbids writing, prints the mode and reads the
standard input to obtain a line. If the line begins with y, the move takes place. If it does not, exits. For further information, see
In the second form, one or more files (plain files or directories) are moved to the directory with their original file-names.
The command refuses to move a file onto itself.
Options
- Interprets all following arguments as file names to allow file names starting with a minus.
-f Force. This option overrides any mode restrictions or the -i switch.
-i Interactive mode. If a move is to supersede an existing file, the system prompts youw with the name of the file fol-
lowed by a question mark. If you type a string that begins with y, the move occurs. If you type any other response,
the move does not occur.
Restrictions
If file1 and file2 lie on different file systems, must copy the file and delete the original. In this case the owner name becomes that of
the copying process and any linking relationship with other files is lost.
See Also
cp(1), ln(1)
mv(1)