Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
Advanced Search and Replace HOWTO?
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.
.... windows_function_call, windows_path'\' ...
if(windows) ... windows_function_call, windows_path'/'... elseif(unix) ... unix_function_call, unix_path'\'...
Last edited by legendbb; 02-08-2013 at 05:59 PM. Reason: resolved
Thanks to google and contributor over Internet. I found my solution.
Share it here
#!/bin/bash FILE=$1 while read -r line doecho $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