Advertisement
phillips321

dk_script.sh

May 15th, 2011
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.01 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. ##############################################################
  4. #dirty script hopefully will replace 2 constant parameters as described below
  5. #######
  6. #target.xml is the file in which 2 parameters will be replaced
  7. #from file1.txt and file2.txt
  8. #the two parameters are constant xxx and yyy
  9. #######
  10.  
  11.  
  12. if [ ${1} = "target.xml"  ]
  13. then
  14.         echo "MESSAGE: target xml given"
  15. else
  16.         echo "MESSAGE: target xml not given"    
  17. fi
  18.  
  19. #######just throwing out the strings  
  20. NUMBER1=`wc -l file1.txt`
  21. STRING1=`cat file1.txt`
  22. COUNT=0
  23. echo "MESSAGE: Found ${NUMBER1} number of strings to replace"
  24. echo "MESSAGE: The strings are ${STRING1}"
  25.  
  26.  
  27. ######using sed to replace the constant####
  28.  
  29. for i in `cat file1.txt` [[I need an AND operator here]]] j in `cat file2.txt`
  30. do
  31.     TARGET1=${i}
  32.     TARGET2=${j}
  33.     echo "replacing xxx with ${TARGET1}"
  34.     echo "replacing yyy with ${TARGET2}"
  35.        
  36.     sed s/xxx/${TARGET1}/g s/yyy/${TARGET2}/g ${1}> ${TARGET1}_output.xml
  37.    
  38.    
  39. done
  40.  
  41. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement