Bash remove anything OUTSIDE quotation marks

bash remove all quotes from string
sed remove single quotes
awk remove double quotes
sed remove quotes and commas
bash remove quotes from input
bash remove quotes around a string
shell delete quotes
bash strip off quotes

I have a curl request, which returns following output:

<a href="spike10-st-d43d7eff66aa.ovpn">pike10-st-d43d7eff66aa.ovpn</a>                 25-Sep-2018 13:49                4947
<a href="spike11-First-d43d7eff66aa.ovpn">spike11-First-d43d7eff66aa.ovpn</a>                 25-Sep-2018 14:04                4951
<a href="spike12-rst-d43d7eff66aa.ovpn">spike12-rst-d43d7eff66aa.ovpn</a>                 25-Sep-2018 14:27                4947
<a href="spike13-irst-d43d7eff66aa.ovpn">spike13-irst-d43d7eff66aa.ovpn</a>                 25-Sep-2018 15:00                4947

Can anyone give me a hint, how to remove all outside quotation marks to receive only names of *.ovpn files, like this:

spike10-st-d43d7eff66aa.ovpn
spike11-First-d43d7eff66aa.ovpn
spike12-rst-d43d7eff66aa.ovpn
spike13-irst-d43d7eff66aa.ovpn

If the input won't contain any extra quotation marks, you can just use cut

cut -d\" -f2 filename

This will delimit on quotation marks, and get the 2nd field. Simple.

A very simple option is to use sed as @Dani proposes if you want to remove all double-quotes. $ echo "This is my program \"Hello World\"" | sed  How to remove Carriage Return (CRLF) within double quotes in a file. There are multiple CRLFs within double quotes. We are on Ubuntu 14.04.2 LTS. The file that we are importing is a csv file from unix to windows and the file was formatted to unix2dos. Therefore all lines in the file all have (12 Replies)

Get value of attribute href with a valid HTML file:

xmlstarlet select --text --template --value-of '//a/@href' -n file.html

Output:

pike10-st-d43d7eff66aa.ovpn
spike11-First-d43d7eff66aa.ovpn
spike12-rst-d43d7eff66aa.ovpn
spike13-irst-d43d7eff66aa.ovpn

See: xmlstarlet select --help

In the attached file I am trying to remove all the "" and , (quotes and commas) from All other commas which is present outside double quotes should be present. Quote type Name Meaning Example (type at shell prompt) " The double quote The double quote ( "quote" ) protects everything enclosed between two double quote marks except $, ', " and \.Use the double quotes when you want only variables and command substitution.

You can use the following to remove anything outside quotation marks:

awk -F\" '{print $2}' file

spike10-st-d43d7eff66aa.ovpn
spike11-First-d43d7eff66aa.ovpn
spike12-rst-d43d7eff66aa.ovpn
spike13-irst-d43d7eff66aa.ovpn

What is the easy way to remove the double quotes in the file in the following format. "asdfa","fdgh","qwer" HTML Code: tr -d '\\"' | The UNIX and Linux Forums. All other commas which is present outside double quotes should be present. How to remove Carriage Return (CRLF) within double quotes in a file. There are multiple CRLFs within double quotes. We are on Ubuntu 14.04.2 LTS. The file that we are importing is a csv file from unix to windows and the file was formatted to unix2dos. Therefore all lines in the file all have (12 Replies)

Could you please try following(considering that your actual Input_file is same as show samples).

awk 'match($0,/href="[^"]*/){print substr($0,RSTART+6,RLENGTH-6)}' Input_file

Just use " for the outer quotes in your sed and you can then use ' in the more than one consecutive " and you want to replace all of them. Python Exercises, Practice and Solution: Write a Python program to extract values between quotation marks of a string.

this regular expression help you to remove unwanted string.

.replace(/(.*)(["])(.*)(["])(.*)/g, '$3')


'<a href="spike10-st-d43d7eff66aa.ovpn">pike10-st-d43d7eff66aa.ovpn</a>                 25-Sep-2018 13:49                4947'.replace(/(.*)(["])(.*)(["])(.*)/g, '$3')

Ctrl + H; Find what: (?:^|\G)[^“”]*(“[^”]*”); Replace with: $1 (Note: there is a space before $1 ); check Wrap around; check Regular expression  SED on multiple quotation marks in BASH. I need to remove the single quotation mark in front of foo at the beginning of each line. I was able to accomplish this with:

How values (numeric, string, char, etc) are displayed is a totally different thing to I would be happy to find out how to remove the apostrophes/single quotes as  If the value you assign to a variable includes spaces, they must be in quotation marks when you assign them to the variable. This is because, by default, Bash uses a space as a delimiter. Here’s an example: site_name=How-To Geek. Bash sees the space before “Geek” as an indication that a new command is starting.

bash: awk sed remove double quotes. awk_sed_remove_double_quotes.sh. #!/​bin/sh. # print 1st field with awk pipe to sed and remove double quotes. Regular Expression to . Character classes. any character except newline \w \d \s: word, digit, whitespace

Table 1.6 gives the meanings of all special characters within shell command lines If you surround a string of characters with single quotation marks (or quotes), the hookah out of its \ > mouth, and addressed her in a languid, sleepy voice. I am looking for a string within quotation marks where the word Linux occurs somewhere between parentheses which reside somewhere inside the quotation marks. I have to use a regular expression to do that.

Comments
  • Use an HTML parser like xmllint or xmlstarlet to extract the value of the href attribute of each a element.
  • Don't Parse XML/HTML With Regex.
  • You ask for the href fields, not the description. Your example is slightly confusing.
  • hi Cyrus sir, you are too good in xmlstarlet just a request if you are interested you could write a whitepaper of your book kind of thing on it since its documentation is not that good, ++ve for solution too.
  • @RavinderSingh13: Thanks for the question, but unfortunately I can't accommodate that in time. Yes, the documentation could be much better.
  • @RavinderSingh13 while I agree that xmlstarlet's documentation is rather sparse, I do believe that 90% of its complexity and misunderstanding comes from XPath which is far from logical. If you understand the latter, it becomes much more interesting. But to my opinion, mastering Xpath comes close to trying to boil an ocean!
  • Please explain what your code is trying to do, not just lines of code.
  • @EriawanKusumawardhono nonsense. Explaining that code would be as useful as adding an incrementing i comment to i++.
  • @EdMorton feel free to disagree. I understand what the code does, but I'm also following SO guidelines: stackoverflow.com/help/how-to-answer To me, adding the remark on what the code does will be helpful for others, especially newbie.
  • @EriawanKusumawardhono, while you're not wrong, the code in this answer is so blatantly obvious that I'd expect anyone who included an awk tag in their question to be able to read and understand it. The code in this answer is infinitely longer and more complex than the awk code in the question .. which is a criticism of the question (which should perhaps be closed) rather than of the answer.