LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   bash script with grep and sed: sed getting filenames from grep (http://www.linuxquestions.org/questions/programming-9/bash-script-with-grep-and-sed-sed-getting-filenames-from-grep-464865/)

odysseus.lost 07-17-2006 09:52 AM

bash script with grep and sed: sed getting filenames from grep
 
Hi I have the following script:

Code:

grep -iH csunix $1
sed 's#/home/csunix/menig/LOCAL_PARTITION/#/usr/not-backed-up/////////////////#g' $1 > $1.tmp && mv $1.tmp $1
echo "Replaced LOCAL_PARTITION"
sed 's#/home/csunix/menig/#/usr/not-backed-up/#g' $1 > $1.tmp && mv $1.tmp $1
echo "Replaced menig"
grep -i csunix $1
echo "OK"

1. I would like the files to be passed to sed to be the output of grep... rather than passing one by one from the command line...
2. How can I preserve the file permissions which are getting lost...

Any clues?

Cheers!

unSpawn 07-17-2006 11:36 AM

/home/csunix
If you don't mind me asking, is this sposed to be your homework?


All times are GMT -5. The time now is 05:43 AM.