Results 1 to 2 of 2
Hi, Gurus,
Just wondering how to script or use tool (technique) to search through multiple files for a string and duplicate the line and change part of the content in ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 02-08-2013 #1
Advanced Search and Replace HOWTO?
Hi, Gurus,
Just wondering how to script or use tool (technique) to search through multiple files for a string and duplicate the line and change part of the content in one of the duplicate.
I have a windows source, I'd like to have an automated way to scan through the code adding OS test statement and Unix version of code.
Example:
automatically changes toCode:.... windows_function_call, windows_path'\' ...
I can manually add those lines but it's very time consuming, and I believe there must be a smart way to do it. And it's cool to know HOWTO.Code:if(windows) ... windows_function_call, windows_path'/'... elseif(unix) ... unix_function_call, unix_path'\'...
Great thanks,Last edited by legendbb; 02-08-2013 at 04:59 PM. Reason: resolved
- 02-08-2013 #2
Thanks to google and contributor over Internet. I found my solution.
Share it here
Code:#!/bin/bash FILE=$1 while read -r line do
echo $line | grep -q '\\'if [ $? -eq 0 ];thenecho if(windows)echo -e "\t$line"echo "elseif(unix)"REPLACE=$(echo $line | sed 's/old/new/')echo -e "\t$REPLACE"elsedone<$FILEecho $line


Reply With Quote
