Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sed script work, oneliner not work, what's the problem?

Status
Not open for further replies.

will27

Technical User
Jun 13, 2007
23
0
0
US
Hi, all
suppose I have following txt file "people"

Tim US
Xue CHN
Will US
Tom US
Yong CHN

if I work with a sedscript as following:
Code:
/US$/ {
s//USA/
w us.origin_1
}
then following code works
Code:
 sed -n -f sedscript people
However, its oneliner version as below doesn't

Code:
sed '/US$/ {s//USA/; w us.origin_1}' people
the error message is:
sed: -e expression #1, char 0: Unmatched `{'

How should I deal with this message?

Thank you

Regards
will
 
Hi

In some cases [tt]sed[/tt] counts on the presence of newline characters :
Code:
sed '/US$/ {s//USA/; w us.origin_1
}' people

[gray]# or[/gray]

sed '/US$/ s//USA/; /USA$/ w us.origin_1' people

Feherke.
 
What about this ?
sed '/US$/{;s//USA/;w us.origin_1;}' people

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
OOps, the w command should be terminated with EOF or EOL.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi

Just one question remaining : why I answered this off-topic question anyway ? [nosmiley]

will, while we have no [tt]sed[/tt] forum here on Tek-Tips, your future [tt]sed[/tt] questions will feet better forum822's topic.

Feherke.
 
Hi,
thanks,
PHV and feherke.
I do agree with feherke that the this thread is somewhat off-topic, I assume people who has expertise on awk will also be familiar with sed.
Anyway, the task can be pretty decently done with awk.

Best
 
Hi

will said:
I assume people who has expertise on awk will also be familiar with sed.
I agree, that is mostly correct.

The reason for choosing the most appropriate forum is not us, but those who will come later and will search the forum archive for similar problem.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top