Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8605041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:43:34+00:00 2026-06-12T02:43:34+00:00

I have a file: @Book{gjn2011ske, author = {Grzegorz J. Nalepa}, title = {Semantic Knowledge

  • 0

I have a file:

@Book{gjn2011ske, 
  author =   {Grzegorz J. Nalepa},
  title =    {Semantic Knowledge Engineering. A Rule-Based Approach},
  publisher =    {Wydawnictwa AGH},
  year =     2011,
  address =  {Krak\'ow}
}

@article{gjn2010jucs,
  Author =   {Grzegorz J. Nalepa},
  Journal =  {Journal of Universal Computer Science},
  Number =   7,
  Pages =    {1006-1023},
  Title =    {Collective Knowledge Engineering with Semantic Wikis},
  Volume =   16,
  Year =     2010
}

I want to improve the regular expression that only removed the first line. Note: The record separator RS="}\n" can not be changed.

I tried:

awk 'BEGIN{ RS="}\n" } {gsub(/@.*,/,"") ; print }' file

I want to print the result:

  author =   {Grzegorz J. Nalepa},
  title =    {Semantic Knowledge Engineering. A Rule-Based Approach},
  publisher =    {Wydawnictwa AGH},
  year =     2011,
  address =  {Krak\'ow}

  Author =   {Grzegorz J. Nalepa},
  Journal =  {Journal of Universal Computer Science},
  Number =   7,
  Pages =    {1006-1023},
  Title =    {Collective Knowledge Engineering with Semantic Wikis},
  Volume =   16,
  Year =     2010

Thank you for your help.

EDIT:

My proposed solution:

awk 'BEGIN{ RS="}\n" }{sub(",","@"); sub(/@.*@/,""); print }' file 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:43:35+00:00Added an answer on June 12, 2026 at 2:43 am

    It’s hard to accomplish what you want with the specified RS setting (because the address = {Krak\'ow} has an extra record ending). I’d rather go with:

    awk '$0 !~ "^@" && $0 !~ "^} *$" { print }' FILE 
    

    See it in action here.

    EDIT I don’t know why it must be with a regexp solution, could you please explain it?

    Anyway, yet another (working, see here) solution which uses regexp(s), but not the ones you are expecting.:

    awk 'BEGIN{ RS="}\n" }
    {
      split($0,a,"\n")
      for (e=1;e<=length(a);e++) {
          if (a[e] ~ "{" && a[e] !~ "}") {
              sub("$","}",a[e])
          }
          if (a[e] ~ "=") { print a[e] }
      }
      printf("\n")
    }' INPUTFILE
    

    One more, with a much simpler regexp, but it fails, with the “address” line as the last } will be removed with your RS, and it will print a final }…

    awk 'BEGIN{ RS="}\n" }
    {
      sub("@[^,]\+,","")
      print $0
    }' INPUTFILE
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML file that looks like this <library> <book> <title>Title</title> <author>author</author> <price>20</price>
I have xml file like this <bookstore> <book category=cooking> <title lang=en>Everyday Italian</title> <author>Giada De
I have an xml file likes below. <?xml version=1.0 encoding=utf-8 ?> <Book> <Title>Title</Title> <Content>Content</Content>
I have a description text file with content constructed in such manner: Book title
I have an xml file with the following data: <BOOKS> <BOOK> <TITLE image=./images/govnahDesign.jpg>Bible</TITLE> <CATEGORY>Book</CATEGORY>
I have a xml file structured like <?xml version=1.0?> <library> <book id=1003> <title>Jquery MVC</title>
I have xml file as below: <Name ns1:translate=yes>Overview</Name> <TextValue>Start</TextValue> <Title ns1:translate=yes>This is a book</Title>
I have books.xml file which contains author name and book titles. I am using
Lets say this is the XML file I have. <bookstore> <book year=1994> <title>blah</title> <price>66</price>
Hoi, for example, i have a xml file : <bookstore> <book category=COOKING> <title lang=en>Everyday

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.