I'm trying to do this exact same thing, so far I have created this to move files
i've named my script CP.sh
When i go to run this in the console i type, bin/sh/ CP.sh
but it comes up
Moderator's Comments:
This thread was split out from a similar thread started by another user.
Please do not hijack existing threads with a new question.
First: Is this a homework assignment? Homework assignments must be posted in the Homework and Coursework Forum and threads started there must include a fully completed homework template.
There are a few problems here:
If you want to execute a bash run it with bash, not sh.
When specifying an absolute pathname for a file; there is a / at the start of the pathname. Putting a / at the end of a pathname declares that the file named by that pathname is a directory (and if there is a file with that name that is not of type directory; it should be ignored for the purposes of resolving that pathname).
Assuming that there is a file with the pathname /root/my-documents/NewDir/x.doc, one of the cp commands run by your loop would try to move the two files /root/my-documents/NewDir/x.doc and /root/my-documents/NewDir/root/my-documents/NewDir to the directory named /root/my-documents/NewDir/x.
Assuming this is not a homework assignment, your immediate problem can be solved by running the script with bash CP.sh (assuming that you have your PATH environment variable set properly) or /bin/bash CP.sh.
But, then you'll run into problems with the cp commands. If you describe what you are trying to do in English, we may be able to help you fix your code.
This User Gave Thanks to Don Cragun For This Post:
I am new user to solaris and installed solaris operating system on full Harddisk 120Gb. I am unable to copy music files to desktop and /home directory.
One thing happened while registering is- i entered login-root and its password. The message prompted your system is crashed. Is it because of... (1 Reply)
hi
I want to copy all files from the current directory and move to .archive file.
Moreover,I want to add .bak to each file name, that will be copied.
How can I do that? (4 Replies)
Hi,
I understand that to copy files across server, the feasible way will be using scp command. Am I right?
What if the two servers are not connected to a network? If by using a cross cable to link up both the server, what will be the best (fastest) way to copy files across? scp as well?
... (3 Replies)
I am userB and have a dir
/temp1
This dir is owned by me.
How do I recursively copy files from another users's dir userA?
I need to preserve the original user who created files, original group information, original create date, mod date etc.
I tried
cp -pr /home/userA/* .
... (2 Replies)
Hi All,
I'm trying to list some files from my log directory
and files are like this
log.20110302_20.gz
log.20110302_21.gz
log.20110302_22.gz
log.20110302_23.gz
log.20110303_00.gz
log.20110303_01.gz
log.20110303_02.gz
............
log.20110311_22.gz
log.20110311_23.gz... (2 Replies)
Hi All,
I am doing this for svn patch making. I got the list of files to make the patch. I have the list in a file with path of all the files.
To Do
From Directory : /myproject/MainDir
To Directory : /myproject/data
List of files need to copy is in the file: /myproject/filesList.txt
... (4 Replies)
Hi,
I have a shell script
#!/bin/sh
date
echo 'HI PROD'
echo $Please ENTER THE INPUT 1 for old files 2 for new file
read i
if ;
then
cd /apps/acetp3_logs/prod3/O*
pwd
echo $PLEASE ENTER THE STRING TO SEARCH (PLEASE ENTER THE STRING INSIDE QUOTES ' ')
read j
echo... (6 Replies)
Hi,
I have a folder which contains files in this format.
abc-bin.000001
abc-bin.000002
abc-bin.000003
abc-bin.000004
abc-bin.000005
abc-bin.000006
abc-bin.000007
abc-bin.000008
abc-bin.000009
abc-bin.000010
abc-bin.index
I want to copy all the files between
abc-bin.000004... (6 Replies)
All,
I need to grab and rename common files from several unique directory structures. For example, the directory structures looks like:
/unique_dir/common/common/common/person_name_dir/common_file.txt
There are over 90,000 of these text files that I'd like to put in a single directory as... (5 Replies)