LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 08-21-2006, 12:10 PM   #1
powah
Member
 
Registered: Mar 2005
Distribution: FC, Gentoo
Posts: 276

Rep: Reputation: 30
sed error : Unknown option to 's'


$ sed -f /home/powah/sed/changePET.sed pet.cpp
sed: file /home/powah/sed/changePET.sed line 2: Unknown option to 's'

/home/powah/sed/changePED.sed is as follows:
s#red PET#beautiful red PET#

$ sed -V
GNU sed version 3.02

Copyright (C) 1998 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.

Linux is: 2.4.7-10smp #1 SMP Thu Sep 6 17:09:31 EDT 2001 i686 unknown
 
Old 08-21-2006, 12:20 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
s#red PET#beautiful red PET#

According to the sed man page, # is used to make a comment.

Try s/red PET/beautiful red PET/ instead.

s/regexp/replacement/
Attempt to match regexp against the pattern space. If successful, replace that portion matched with replacement. The
replacement may contain the special character & to refer to that
portion of the pattern space which matched, and the special
escapes \1 through \9 to refer to the corresponding matching
sub-expressions in the regexp.
 
Old 08-21-2006, 01:05 PM   #3
powah
Member
 
Registered: Mar 2005
Distribution: FC, Gentoo
Posts: 276

Original Poster
Rep: Reputation: 30
I tried first
s/red PET/beautiful red PET/
but got the error "Unknown option to 's'", so
I tried s#red PET#beautiful red PET#
but still got the same problem, after googling for a while but does not get an answer, finally I posted to this forum.
 
Old 08-21-2006, 02:11 PM   #4
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
I don't know why you get an error as it works on my FC5 box.

cat file.txt
I have a red PET
and some more
stuff here.

cat myscript
s/red PET/beautiful red PET/

Code:
sed -f myscript file.txt
I have a beautiful red PET
and some more
stuff here.

sed --version
GNU sed version 4.1.5
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.
 
Old 01-04-2012, 03:52 PM   #5
shantanu18
LQ Newbie
 
Registered: Aug 2011
Posts: 4

Rep: Reputation: Disabled
s/red PET/beautiful red PET/ [your are missing a single quote]

sed 's/red PET/beautiful red PET/' file.txt
 
  


Reply


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
rpm --rebuild gives error/unknown option acidblue Fedora 1 04-10-2006 11:39 PM
xvt: unknown option '-n' nfreeman Linux - Software 0 10-08-2005 11:31 AM
pnetlib-0.6.12 error unknown option 'base_type' DropSig Linux - Software 0 05-05-2005 12:29 AM
pnetlib-0.6.12 error unknown option 'base_type' DropSig Linux - Software 0 05-04-2005 02:18 PM
rpm -bb : unknown option stevie_velvet Linux - Enterprise 4 09-08-2004 09:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:27 PM.

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