![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Auto copy for files from folder to folder upon instant writing | Bashar | UNIX for Advanced & Expert Users | 2 | 1 Week Ago 11:44 AM |
| Find a file in a folder-please help | bsandeep_80 | UNIX for Dummies Questions & Answers | 7 | 04-17-2008 12:21 AM |
| Parse the .txt file for folder name and FTP to the corrsponding folder. | MeganP | Shell Programming and Scripting | 3 | 07-03-2007 10:54 AM |
| how to differentiate a file from a folder in a FIND? | denysQC | UNIX for Dummies Questions & Answers | 3 | 06-06-2006 03:02 PM |
| Find an imported folder? | gilr | UNIX for Dummies Questions & Answers | 2 | 03-27-2002 02:08 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Take a folder name and find it in another folder (Complicated)
Hi Script Experts,
Here is my scenario: 1. /var/mqm/qmgrs folder will contain 11 folders as follows: 1. /var/mqm/qmgrs/Folder_Name1 ....................../Folder_Name2 ....................../Folder_Name3 ....... ...................../Folder_Name11 2. if Folder_Name1 exists in /export/home/mqm/DR/ini/Folder_Name1 then delete Folder_Name1 from step 1. /var/mqm/qmgrs folder 3. Go back in the loop, take Folder_Name2 and perform step 2. until all 11 Folder_Name11 NOTE: I did ls -1 /var/mqm/qmgrs/. which is giving me a list of Folder_Name1 thru Folder_Name11 I don't know how to take Folder_Name1 value and see if it exists in step 2 folder. If somebody can help me here would be highly appreciated!!! Warm Regards, Khan |
| Forum Sponsor | ||
|
|
|
|||
|
BlowTorch and Raj,
Thank you so much for all your help. It is working great. I really appreciate it. I have a similar situation where I like do the following: Here is my scenario: 1. /var/mqm/qmgrs folder will contain 11 folders as follows: 1. /var/mqm/qmgrs/Folder_Name1 ....................../Folder_Name2 ....................../Folder_Name3 ....... ...................../Folder_Name11 2. if Folder_Name1 exists in /export/home/mqm/DR/ini/Folder_Name1 then update a LogPath line in qm.ini file within /var/mqm/qmgrs/Folder_Name1/qm.ini file 3. Go back in the loop, take Folder_Name2 and perform step 2. until all 11 Folder_Name11 NOTE: This is what I tried, it is generating a new file under /var/mqm/qmgrs but NOT updating the LogPath line in the qm.ini file. Code:
cd /var/mqm/qmgrs/
for dir in *; do
if [ -d /export/home/mqm/DisasterRecovery/ini/$dir ]; then
echo updating Log Path for $PWD/$dir
sed -e '/^ LogPath/s/LogPath=\var\/mqm\/log\/$dir\/
$dir\//LogPath=\/var\/mqm\/log\/$dir\//' /var/mqm/qmgrs/
$dir/qm.ini >ini.new
fi
done
sed -e '/^ LogPath/s/LogPath=\/var\/mqm\/log\/CIBOTSP\/CIBOTSP\// LogPath=\/var\/mqm\/log\/CIBOTSP\//' qm.ini.new > qm.ini Could you please help me out here. Warm Regards, Khan Last edited by blowtorch; 09-06-2006 at 09:20 AM. Reason: add code tags |
|
||||
|
Not really able to understand what you are doing in that sed there. Why don't you give an example for one directory name and then someone could help you with what you want.
Here's a tip: when using sed to match/replace for pathnames that contain the "/" character, don't use the "/" as the delimiter/seperator for the sed commands. Use something like "#" instead. Code:
sed -e 's#LogPath#lOGpATH#g' somefile Code:
sed -e 's/LogPath/lOGpATH/g' somefile |
||||
| Google UNIX.COM |