![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| find and replace string in a directory files | koti_rama | Shell Programming and Scripting | 2 | 05-30-2008 12:48 AM |
| Need to search and replace in multiple files in directory hierarchy | umen | Shell Programming and Scripting | 3 | 12-24-2007 01:56 AM |
| Replace a Directory path with another in a file | venkatajay_18 | Shell Programming and Scripting | 3 | 10-17-2006 12:52 PM |
| Replace characters in all file names in a particular directory | madhunk | Shell Programming and Scripting | 4 | 02-16-2006 04:10 PM |
| moving files from a unix directory to a windows directory | gleads | UNIX for Dummies Questions & Answers | 2 | 08-29-2002 05:42 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I am using the find command to get a list of files in a directory with all of it's sub directories and I put that in a temp file. I then want to read through that list and use the copy command to copy them to another directory for a db backup. How would I change the directory name of the files while I am looping through the file. For example:
I have a file /u01/mydb/TEST/datafile1.dbf in a variable $fn. I want to change the directory to /u02/backup/TEST/datafile1.dbf. How do I do that? I tried sed and it didn't work to well. I also tried tr but it wasn't working. Thanks for your help. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
You didn't say which shell you are using, but in ksh you can do...
var=/u02/backup/${fn#/u01/mydb/} Note: ${fn#pattern} means remove pattern from the beginning of $fn |
|
#3
|
|||
|
|||
|
Thanks.
That works. Thanks.
|
|||
| Google The UNIX and Linux Forums |