|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Script to change unix path to windows path in all files
I need a shell script to recursively read through a directory and change all instances in a program of /var/www/html/ to /www/Apache2/htdocs/. Additionally I want it to print the full path and name of the file it changed. I can use bash or csh or even perl.
Thank you |
|
#2
|
||||
|
||||
|
Oookay, let's see if we can give some pointers here!
grep -l "text" * will list the names of all files with "text" in them in current directory, so only those files need be processed. If you want to start in one directory and also in all sub-directories underneath, you can change to that base directory and issue a find . -type d to list all directories to check. If it is just one directory then a simple cd will suffice. (I can foresee a potential two parms: one for recursion and one for start directory). Now, working on one dir at a time, we know a) the dir name and b) the files, and from those, we can 'do' one file at a time, within 1 dir at a time. From those we can print the full path and name. You will want to work on a copy of the file, and then rename the copy once it has been processed. To do a bulk edit of a file you will want to look at sed That is the 'logic' as I see it - the code/implementation would be up to you. |
![]() |
| Viewing: Dev Shed Forums > Web Site Management > Scripts > Script to change unix path to windows path in all files |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|