Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 04-21-2004, 12:28 AM   #1
Senior Member
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
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?

Old 04-21-2004, 01:15 PM   #2
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to write a bash script to replace all "KH" to "K" in file ABC??? cqmyg5 Slackware 4 07-24-2007 09:00 AM
Replacing "function(x)" with "x" using sed/awk/smth Griffon26 Linux - General 3 11-22-2006 10:47 AM
Using sed to replace a lot of text Wynd Programming 9 10-07-2005 03:47 AM
how can i replace "lilo" with "grub"....... b0nd Linux - Newbie 5 04-18-2005 04:52 AM
1. shell script "find and replace" on text 2. java GUI application randomx Programming 4 03-05-2004 01:01 PM

All times are GMT -5. The time now is 05:32 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration