Sponsored Content
Top Forums Shell Programming and Scripting moving files from a dir in one machine to a dir in another machines Post 302440508 by mathews on Tuesday 27th of July 2010 11:12:55 AM
Old 07-27-2010
Thanks.But that is not what I am looking for. I will be getting the list of READ WRITE files that need to be moved by -

#!/bin/ksh
sqlplus -s "/ as sysdba" <<EOF>W1KK_dbfiles.txt
set heading off feedback off verify off
SELECT name FROM v$datafile WHERE ENABLED='READ WRITE';
exit;
EOF

the database w1kk is on a machine, say m1 and the database w2kk is on another machine, say m2. The directory structures where the datafiles are located are almost the same. On machine m1 it is-
/u01/oradata/w1kk
/u02/oradata/w1kk
/u03/oradata/w1kk
..
..
..

and on machine m2, it is
/u01/oradata/w2kk
/u02/oradata/w2kk
/u03/oradata/w2kk
..
..
..


Once I identify the files that need to be scp-ed, I need to move the file
/u01/oradata/w1kk to /u01/oradata/w2kk
/u02/oradata/w1kk to /u02/oradata/w2kk
/u03/oradata/w1kk to /u03/oradata/w2kk

I tried to use sed to replace the w1kk to w2kk bu it didnt work. I just didn't know how to do it. This is what I tried with sed -

#!/bin/ksh
sqlplus -s "/ as sysdba" <<EOF>W1KK_dbfiles.txt
set heading off feedback off verify off
SELECT name FROM v$datafile WHERE ENABLED='READ WRITE';
exit;
EOF

for i in `cat W1KK_dbfiles.txt`
do
echo $i
echo `sed 's/W1KK/W2KK/g' $i `
done


This is wrong because - it tells me it doesn't identify $i as a file and second, it loops through the W1KK_dbfiles.txt for all the records, instead of using sed to act on each line of the file. I am just lost. Can someone please help?

Last edited by mathews; 07-27-2010 at 02:32 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

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... (4 Replies)
Discussion started by: SirJoeh
4 Replies

2. Shell Programming and Scripting

need to move files of particular day from one dir to another dir

Hi, I have hundered's of files of the name CMP_PORT_IN_P200903271623042437_20090328122430_err.xml in error directory of todays date ie 20090328 and in the file name 5th field specifies date only now i want to move all files of 20090328 to another directory i.e reprocess directory. So... (3 Replies)
Discussion started by: ss_ss
3 Replies

3. Shell Programming and Scripting

moving dir subdir and files

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

A script to find dir, delete files in, and then del dir?

Hello!! I have directories from 2008, with files in them. I want to create a script that will find the directoried from 2008 (example directory: drwxr-xr-x 2 isplan users 1024 Nov 21 2008 FILES_112108), delete the files within those directories and then delete the directories... (3 Replies)
Discussion started by: bigben1220
3 Replies

5. UNIX for Dummies Questions & Answers

get all files under specified dir and zip them, then transfer to another machine

Hi guys, now, I have the following requirement: 1. Get all files under specified directory 2. the files modify date should be specified date 3. zip these files 4. transfer these files to another machine, assume ip, user and password are given. could you pls provide good solution for... (1 Reply)
Discussion started by: crest.boy
1 Replies

6. UNIX for Dummies Questions & Answers

How to list all files in dir and sub-dir's recursively along with file size?

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

7. Shell Programming and Scripting

Need a script to move the files from one dir to other other dir

Need a script to move the files from one dir to other dir and at the same time it has to read the log in the source dir. Please help me ASAP. (4 Replies)
Discussion started by: viswanathkishor
4 Replies

8. Shell Programming and Scripting

Copy files and subdirs from dir to a new dir

Hello Comunity I am trying to make a bash shell script that it copies files and subdirs(with files) to a new dir. I would like the dest_dir to contain only subdirectories with files not other subdirs inside. it called : cpflatdir src_dir dest_dir Pleaze help me! Thank you in... (2 Replies)
Discussion started by: BTKBaaMMM
2 Replies

9. Shell Programming and Scripting

KSH - Find paths of multiple files in CC (dir and sub-dir))

Dear Members, I have a list of xml files like abc.xml.table prq.xml.table ... .. . in a txt file. Now I have to search the file(s) in all directories and sub-directories and print the full path of file in a output txt file. Please help me with the script or command to do so. ... (11 Replies)
Discussion started by: Yoodit
11 Replies

10. AIX

Assign read write permission to the user for specific dir and it's sub dir and files in 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)							    BSD General Commands Manual 						     MV(1)

NAME
mv -- move files SYNOPSIS
mv [-f | -i | -n] [-v] source target mv [-f | -i | -n] [-v] source ... directory DESCRIPTION
In its first form, the mv utility renames the file named by the source operand to the destination path named by the target operand. This form is assumed when the last operand does not name an already existing directory. In its second form, mv moves each file named by a source operand to a destination file in the existing directory named by the directory oper- and. The destination path for each operand is the pathname produced by the concatenation of the last operand, a slash, and the final path- name component of the named file. The following options are available: -f Do not prompt for confirmation before overwriting the destination path. (The -f option overrides any previous -i or -n options.) -i Cause mv to write a prompt to standard error before moving a file that would overwrite an existing file. If the response from the standard input begins with the character 'y' or 'Y', the move is attempted. (The -i option overrides any previous -f or -n options.) -n Do not overwrite an existing file. (The -n option overrides any previous -f or -i options.) -v Cause mv to be verbose, showing files after they are moved. It is an error for either the source operand or the destination path to specify a directory unless both do. If the destination path does not have a mode which permits writing, mv prompts the user for confirmation as specified for the -i option. As the rename(2) call does not work across file systems, mv uses cp(1) and rm(1) to accomplish the move. The effect is equivalent to: rm -f destination_path && cp -pRP source_file destination && rm -rf source_file DIAGNOSTICS
The mv utility exits 0 on success, and >0 if an error occurs. The command "mv dir/afile dir" will abort with an error message. LEGACY DIAGNOSTICS
In legacy mode, the command "mv dir/afile dir" will fail silently, returning an exit code of 0. For more information about legacy mode, see compat(5). SEE ALSO
cp(1), rm(1), symlink(7) COMPATIBILITY
The -n and -v options are non-standard and their use in scripts is not recommended. The mv utility now supports HFS+ Finder and Extended Attributes and resource forks. The mv utility will no longer strip resource forks off of HFS files. For an alternative method, refer to cp(1). STANDARDS
The mv utility is expected to be IEEE Std 1003.2 (``POSIX.2'') compatible. HISTORY
A mv command appeared in Version 1 AT&T UNIX. BSD
July 9, 2002 BSD
All times are GMT -4. The time now is 09:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy