LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   can I replace text with the result of "wc" using sed? (http://www.linuxquestions.org/questions/linux-general-1/can-i-replace-text-with-the-result-of-wc-using-sed-172738/)

BrianK 04-21-2004 12:28 AM

can I replace text with the result of "wc" using sed?
 
I'm trying to send an automated report.

I have a file I want to mail to myself. In that file, I want to replace xxxx with the result of "wc -l somefile". I've tried:

sed s/xxxx/`wc -l somefile`/g message

but I get the message:

sed: -e expression #1, char 7: Unterminated `s' command

Am I missing a flag? Should it not be a s///g type of sed?

Thanks.

david_ross 04-21-2004 01:15 PM

What about putting the expression in quotes:
sed 's/xxxx/`wc -l somefile`/g' message


All times are GMT -5. The time now is 09:46 AM.