[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: SED help........



Ralph Crongeyer 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

but sed givs me this error:
sed: -e expression #1, char 23: Unknown option to 's'

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?

Can someone help me with this?

Ralph



It's difficult to tell exactly what your 2 expressions are. But I see forward slashes (/'s) all over that. To use an s commad through sed is:

sed 's/searchFor/replaceWith/'

so if you have any "/" inside your expressions you need to escape them:

sed 's/search\/For/replace\/With/'

If you look at the error msg again "char 23: Unkown option", it's picking your 3rd slash in char position 22 as the final / delimiter for the s command.



Reply to: