sed - please help me

February 03rd, 2012 - 03:56 pm ET by Szyk | Report spam
Hi

I want extract class names from C++ file sources. So I think sed will
perfeclty fit my needs. I wrote two almos identical sed commands, but
second completly does not work. Please tell me why?

First command:
$ sed -n '/^class[[:space:]]\+[[:alpha:]]\+.*$/p' ./User.h
class RoomState
class UserBase
class UserData : public UserBase
class User : public UserBase

And similiar but with simple transformation:
$ sed -n 's/^class[[:space:]]\+\([[:alpha:]]\+\).*$/\1/' ./User.h
[no output]


thank you
Szyk
email Follow the discussionReplies 4 repliesReplies Make a reply

Replies

#1 Baho Utot
February 03rd, 2012 - 05:59 pm ET | Report spam
Szyk wrote:

Hi

I want extract class names from C++ file sources. So I think sed will
perfeclty fit my needs. I wrote two almos identical sed commands, but
second completly does not work. Please tell me why?

First command:
$ sed -n '/^class[[:space:]]\+[[:alpha:]]\+.*$/p' ./User.h


^


class RoomState
class UserBase
class UserData : public UserBase
class User : public UserBase

And similiar but with simple transformation:
$ sed -n 's/^class[[:space:]]\+\([[:alpha:]]\+\).*$/\1/' ./User.h


^
[no output]


thank you
Szyk




Missing /p at the end

Similar topics