Find the answer to your Linux question:
Results 1 to 5 of 5
hi every body: please help me , what is the command to retrieve words between { and }. example the page is like this: I am working on {linux} {unix} ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2005
    Location
    pune
    Posts
    3

    help needed: what is the command to retrieve words between { and }.


    hi every body:

    please help me ,
    what is the command to retrieve words between { and }.

    example the page is like this:
    I am working on {linux}
    {unix} {linux} are similar to each other
    {linux}{solaris}{HP-AIX} are the different flavors of {unix}

    so the output should be :
    linux
    unix
    linux
    linux
    solaris
    HP-AIX
    unix
    please help me by providing the command to retrieve words present in between " { "and " } ".

    with Regards and Thanks,
    Rajesh

  2. #2
    Just Joined!
    Join Date
    Jul 2004
    Posts
    94
    The command you are looking for is char *rtvtbbr(const char* s), which stands for "retrieve text between braces." Just "man" that function on your system.

    *****

    Sorry, your question is quite ill-stated, and I could not resist. In what language are you programming? If I were to solve the same problem, I would just write a function that would check the input string for an opening brace, then look for the corresponding closing brace, and then copy the substring to a destination string.

    However, if you already know what strings might be found between the braces, you can use the function char *strstr(const char* haystack, const char *needle) to extract the text without writing any custom function yourself. Just "man" that function.

  3. #3
    Just Joined!
    Join Date
    Nov 2005
    Location
    pune
    Posts
    3

    help needed: new to unix environement

    hi every body:
    I am new to solaris(UNIX) environement.
    please help me ,
    what is the command to retrieve words between { and }.

    example the page is like this:
    I am working on {linux}
    {unix} {linux} are similar to each other
    {linux}{solaris}{HP-AIX} are the different flavors of {unix}

    so the output should be :
    linux
    unix
    linux
    linux
    solaris
    HP-AIX
    unix
    please help me by providing the command to retrieve words present in between " { "and " } ".

    with Regards and Thanks,
    Rajesh

  4. #4
    Linux Newbie
    Join Date
    Jul 2005
    Location
    Chd,India
    Posts
    135
    Why did u type your post again
    If u were trying to do that in perl,you could do this
    Code:
    @list = /{([^}])*}/g;
    print "@list";
    The strong shall live and the weak will die
    In the end,only the fittest survive in this world
    - Shishio Makoto

  5. #5
    Just Joined!
    Join Date
    Nov 2005
    Location
    pune
    Posts
    3
    hello sir,

    I tried the command /{([^}])*}/g but not working on solaris bash shell.
    actually I ahve to retrieve some prompts present in differnet pages and the page format would be same as given in the example.

    so I gave the command (being in that directory where the pages are available)
    grep { * | cut -f 2 -d "{"
    and the output is like this(for above given example)
    linux}
    unix} {linux} are similar to each other
    linux}{solaris}{HP-AIX} are the different flavors of {unix}

    well If I use another cut operation I will get these:
    linux
    unix
    linux

    but I also want solaris and HP-AIX to be displayed, which are present in the same line.
    well in my actual files I dont know what are the words present .



    please help me by providing the command to retrieve words present in between " { "and " } ".

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •