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 8025155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:04:27+00:00 2026-06-04T23:04:27+00:00

I’ve been racking my brain with this for the past half an hour and

  • 0

I’ve been racking my brain with this for the past half an hour and everything I’ve tried so far has failed miserably!

Within an html file, there is a field within tags, but the field itself is not separated with a space from the > sign so it’s hard to read with awk. I would basically like to add a single space after the opening tag, but gsub and awk are refusing to cooperate.

I’ve tried

awk 'gsub("class\\\'\\\'>","class\\\'\\\'>")' filename

since one backslash is needed to escape the single quote, the second to escape the backslash itself, and the third to escape the sequence \’ but Terminal (I’m working on a Mac) refuses to execute, and instead goes in the next line awaiting some other input from me.

Please help 🙁

  • 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-04T23:04:28+00:00Added an answer on June 4, 2026 at 11:04 pm

    In Bash, single quotes accept absolutely no kind of escape. Suppose e.g. I write this command:

    $ echo '\''
    >
    

    Bash will consider the string opened by ' closed at the second ', generating a string containing only \. The next ', then, is considered the opening of a new string, so bash expects for more input in the next line (signalled by the >).

    If you are not aware of this fact, you may think that the string after the echo command below will be open yet, but it is closed:

    $ echo 'will this string contain a single quote like \'
    will this string contain a single quote like \
    

    So, when you write

    'gsub("class\\\'\\\'>","class\\\'\\\'> ")' 
    

    you are writing the string gsub("class\\\ concatenated with a backslash and a quote (\'); then a greater than signal. After this, the "," is interpreted as a string containing a comma, because the single quote of the beginning of the expression was closed before. For now, the result is:

    gsub("class\\\\'>,
    

    After the comma, you have the string class, followed by a backslash and a quote, followed by another backslash and another quote, and finally by a greater than symbol and a space. This is the current string:

    gsub("class\\\\'>,class\'\'> 
    

    This is no valid awk expression! Anyway, it gets worse: the double quote " will start a string, which will contain a closing parenthesis and a single quote, but this string is never closed!

    Summing up, your problem is that, if you opened a string with ' in Bash, it will be forcedly close at the next ', no matter how many backslashes you put before it.

    Solution: you can make some tricks opening and closing strings with ' and " but it will become cumbersome quickly. My suggested solution is to put your awk expression in a file. Then, use the -f flag from awk – this flag will make awk to execute the following file:

    $ cat filename # The file to be changed
    class''>
    class>
    class''>
    $ cat mycode.awk  # The awk script
    gsub("class''>", "class''>[PSEUDOSPACE]")
    $ awk -f mycode.awk filename  # THE RESULT!
    class''>[PSEUDOSPACE]
    class''>[PSEUDOSPACE]
    

    If you do not want to write a file, use the so called here documents:

    $ awk -f- filename <<EOF 
    gsub("class''>", "class''>[PSEUDOSPACE]")
    EOF
    class''>[PSEUDOSPACE]
    class''>[PSEUDOSPACE]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,

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.