![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| noob help needed | ace_face | Linux | 1 | 04-20-2008 08:23 PM |
| unix noob help with awk? | AnnaLynn | Shell Programming and Scripting | 11 | 04-01-2008 09:29 AM |
| Unix Noob, wat do i need etc | skylin3fr3ak | UNIX for Dummies Questions & Answers | 2 | 02-24-2008 11:17 AM |
| complete noob | avdrummerboy | UNIX for Dummies Questions & Answers | 3 | 12-04-2006 12:25 PM |
| I am a unix noob | alt+f4 | UNIX for Dummies Questions & Answers | 4 | 04-28-2006 09:01 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Hi all,
I am trying to write a shell script that will move files from one directory to another, the only thing is I want to to check loads of different source directory and move the files to loads of different directories. I am totally new to shell scripts but not to UNIX (although I would still class myself as a newbie). Any advice would be welcome, as I am sat looking at a rather empty page in vi and goggling like crazy but not coming up with much. |
|
||||
|
You are kinda vague. If you need to move a whole tree try something like this:
Code:
cd /path/to/upper/level/of/source tar -cvf - $(find . -print -type f) | (cd ../destination ; tar -xvf -) |
|
||||
|
Ok, being new to this I have drawn a pic to help me explain......
![]() ok hopefully this will help me explain what I'm trying to do. I did ls | wc -l on /user and that gave 392, which sounds about right (give or take 15 random other directories and files that are in there). So I am trying to move files from one private folder (under xxxx.old) to the other private folder, I need to do this somewhere in the region of 350 times on different folders. Apologies for my naff explanation but hopefully my wonderful picture will give you a clue what I'm on about ![]() |
|
||||
|
Cheers, looks like just what i'm after, however I am getting a syntax error on line 5 (syntax error at line 5: `mNewPriv=$' unexpected), the only thing I have changed is the find (see below).
I have been through I a couple of time to check what I have typed in vi matches your solution, and I am sure I have typed it correctly. Code:
for mNewDir in `find /user/ -type d -name 'accu*.old'`
do
mNewBase=`basename ${mNewDir}`
mNewPriv=${mNewDir}"/private/"
mOldPriv="/user/dotolds/"${mNewBase}".old/private/"
echo "Now copying from "${mOldPriv}" to "${mNewPriv}
#####cp ${mOldPriv} ${mNewPriv}
done
|
|
|||||
|
Sax,
The "find" statement is to loop through all the "accuNNN" directories, NOT the "accu*old". Display the "mNewDir" right after the "do" to see what value you are getting: Code:
echo "mNewDir = <"${mNewDir}">"
|
|
||||
|
I think I see how it's working now.
I changed the find back, and changed the script to ksh. I also added the line above. When I run it I don't get any errors, but then I don't get anything else ? I left the copy command commented out and ran it, but I didn't get any output, I thought I would at least see the echo lines ![]() |
| Sponsored Links | ||
|
|