on Fri, Apr 23, 2004 at 11:39:32AM -0400, Ralph Crongeyer (ralph@crongeyer.com) wrote:
> Hi all,
>
> I need some help with SED. I'm trying to insert a "command"/text at the
> beginning of every line from one file and output to a new file like this:
>
> sed 's/.*/clamscan -ri -l /var/log/clamav/clamav-"$1".log
> --move=/var/log/clamav/quarantine &/ /var/log/clamav/diff/diff.txt >
> /var/log/clamav/virus_scan
Showing a sample of the lines you're trying to change would be useful.
It's hard to tell just from your (broken) regex substitution.
> but sed givs me this error:
> sed: -e expression #1, char 23: Unknown option to 's'
A few things.
- ".*" matches the whole line. Is this what you're trying to change?
If you just want to match start of line, use '^' instead.
- "/" is the default sed argument delimiter. If you're using "/"
within your regex *OR* substitution, you must escape it ("\/") *OR*
use an alternate delimiter. Generally some syntactic character will
work, any of: ".,:|", etc.
- sed expressions must be contained on one line.
- sed expressions on the shell should include *both* open *and* close
quotes.
I think what you want is the following:
sed 's,^,clamscan -ri -l /var/log/clamav/clamav-"$1".log --move=/var/log/clamav/quarantine,' \
< /var/log/clamav/diff/diff.txt > /var/log/clamav/virus_scan
> I have also tried to use the insert command i\ but it just inserts the
> text on a new line above each of the lines read from the file instead of
> just inserting the text at the beginning of each of the lines red from
> the file?
s/red/read/
Correct.
Peace.
--
Karsten M. Self <kmself@ix.netcom.com> http://kmself.home.netcom.com/
What Part of "Gestalt" don't you understand?
Save Bob Edwards! http://www.savebobedwards.com/
Attachment:
signature.asc
Description: Digital signature