Skip to main content
Rollback to Revision 3
Source Link
Michael Mrozek
  • 95.8k
  • 40
  • 245
  • 236

FINAL SOLUTION (for people in the future) I used the plutil command to convert the plist to proper text since it was a 'binary file'. Once that was done, grep had no problem managing the file.

I know a fair bit about escape characters in BASH. I know that \ will escape the next character, " " will escape all characters except for $ and ", and finally ' ' will escape all characters except for '. So if for example I have text with some single quotes ' in it, I can put " " around it to make it behave like a single text string. The problem I have is when my file contains both double and single quote characters. Then, I cannot use either type of quotes to escape it. So how do I ask bash to treat it as a single string?

Context: My iPhone's /var/mobile/Library/Safari/History.plist file. It contains something like:

  <key>
    <string>http://example.com/folder/index.html</string>
    <string>Title of Webpage which may include ' and "</string>
  </key>

I want to cat the file, pass it through grep to take the first line containing the text string and extract the URL from that. But grep chokes on all the quotes.

Edit 1: Here are some screenshots of nano failing to read the file. Cat gives similar output. The graphical file editor iFile reads it as text. http://cloudrac3r.ddns.net/strange.html I am told this is what binary files do. I will do some experimenting.

FINAL SOLUTION (for people in the future) I used the plutil command to convert the plist to proper text since it was a 'binary file'. Once that was done, grep had no problem managing the file.

I know a fair bit about escape characters in BASH. I know that \ will escape the next character, " " will escape all characters except for $ and ", and finally ' ' will escape all characters except for '. So if for example I have text with some single quotes ' in it, I can put " " around it to make it behave like a single text string. The problem I have is when my file contains both double and single quote characters. Then, I cannot use either type of quotes to escape it. So how do I ask bash to treat it as a single string?

Context: My iPhone's /var/mobile/Library/Safari/History.plist file. It contains something like:

  <key>
    <string>http://example.com/folder/index.html</string>
    <string>Title of Webpage which may include ' and "</string>
  </key>

I want to cat the file, pass it through grep to take the first line containing the text string and extract the URL from that. But grep chokes on all the quotes.

Edit 1: Here are some screenshots of nano failing to read the file. Cat gives similar output. The graphical file editor iFile reads it as text. http://cloudrac3r.ddns.net/strange.html I am told this is what binary files do. I will do some experimenting.

I know a fair bit about escape characters in BASH. I know that \ will escape the next character, " " will escape all characters except for $ and ", and finally ' ' will escape all characters except for '. So if for example I have text with some single quotes ' in it, I can put " " around it to make it behave like a single text string. The problem I have is when my file contains both double and single quote characters. Then, I cannot use either type of quotes to escape it. So how do I ask bash to treat it as a single string?

Context: My iPhone's /var/mobile/Library/Safari/History.plist file. It contains something like:

  <key>
    <string>http://example.com/folder/index.html</string>
    <string>Title of Webpage which may include ' and "</string>
  </key>

I want to cat the file, pass it through grep to take the first line containing the text string and extract the URL from that. But grep chokes on all the quotes.

Edit 1: Here are some screenshots of nano failing to read the file. Cat gives similar output. The graphical file editor iFile reads it as text. http://cloudrac3r.ddns.net/strange.html I am told this is what binary files do. I will do some experimenting.

added 201 characters in body
Source Link
user171641
user171641

FINAL SOLUTION (for people in the future) I used the plutil command to convert the plist to proper text since it was a 'binary file'. Once that was done, grep had no problem managing the file.

I know a fair bit about escape characters in BASH. I know that \ will escape the next character, " " will escape all characters except for $ and ", and finally ' ' will escape all characters except for '. So if for example I have text with some single quotes ' in it, I can put " " around it to make it behave like a single text string. The problem I have is when my file contains both double and single quote characters. Then, I cannot use either type of quotes to escape it. So how do I ask bash to treat it as a single string?

Context: My iPhone's /var/mobile/Library/Safari/History.plist file. It contains something like:

  <key>
    <string>http://example.com/folder/index.html</string>
    <string>Title of Webpage which may include ' and "</string>
  </key>

I want to cat the file, pass it through grep to take the first line containing the text string and extract the URL from that. But grep chokes on all the quotes.

Edit 1: Here are some screenshots of nano failing to read the file. Cat gives similar output. The graphical file editor iFile reads it as text. http://cloudrac3r.ddns.net/strange.html I am told this is what binary files do. I will do some experimenting.

I know a fair bit about escape characters in BASH. I know that \ will escape the next character, " " will escape all characters except for $ and ", and finally ' ' will escape all characters except for '. So if for example I have text with some single quotes ' in it, I can put " " around it to make it behave like a single text string. The problem I have is when my file contains both double and single quote characters. Then, I cannot use either type of quotes to escape it. So how do I ask bash to treat it as a single string?

Context: My iPhone's /var/mobile/Library/Safari/History.plist file. It contains something like:

  <key>
    <string>http://example.com/folder/index.html</string>
    <string>Title of Webpage which may include ' and "</string>
  </key>

I want to cat the file, pass it through grep to take the first line containing the text string and extract the URL from that. But grep chokes on all the quotes.

Edit 1: Here are some screenshots of nano failing to read the file. Cat gives similar output. The graphical file editor iFile reads it as text. http://cloudrac3r.ddns.net/strange.html I am told this is what binary files do. I will do some experimenting.

FINAL SOLUTION (for people in the future) I used the plutil command to convert the plist to proper text since it was a 'binary file'. Once that was done, grep had no problem managing the file.

I know a fair bit about escape characters in BASH. I know that \ will escape the next character, " " will escape all characters except for $ and ", and finally ' ' will escape all characters except for '. So if for example I have text with some single quotes ' in it, I can put " " around it to make it behave like a single text string. The problem I have is when my file contains both double and single quote characters. Then, I cannot use either type of quotes to escape it. So how do I ask bash to treat it as a single string?

Context: My iPhone's /var/mobile/Library/Safari/History.plist file. It contains something like:

  <key>
    <string>http://example.com/folder/index.html</string>
    <string>Title of Webpage which may include ' and "</string>
  </key>

I want to cat the file, pass it through grep to take the first line containing the text string and extract the URL from that. But grep chokes on all the quotes.

Edit 1: Here are some screenshots of nano failing to read the file. Cat gives similar output. The graphical file editor iFile reads it as text. http://cloudrac3r.ddns.net/strange.html I am told this is what binary files do. I will do some experimenting.

Added "Edit 1".
Source Link
user171641
user171641

I know a fair bit about escape characters in BASH. I know that \ will escape the next character, " " will escape all characters except for $ and ", and finally ' ' will escape all characters except for '. So if for example I have text with some single quotes ' in it, I can put " " around it to make it behave like a single text string. The problem I have is when my file contains both double and single quote characters. Then, I cannot use either type of quotes to escape it. So how do I ask bash to treat it as a single string?

Context: My iPhone's /var/mobile/Library/Safari/History.plist file. It contains something like:

  <key>
    <string>http://example.com/folder/index.html</string>
    <string>Title of Webpage which may include ' and "</string>
  </key>

I want to cat the file, pass it through grep to take the first line containing the text string and extract the URL from that. But grep chokes on all the quotes.

Edit 1: Here are some screenshots of nano failing to read the file. Cat gives similar output. The graphical file editor iFile reads it as text. http://cloudrac3r.ddns.net/strange.html I am told this is what binary files do. I will do some experimenting.

I know a fair bit about escape characters in BASH. I know that \ will escape the next character, " " will escape all characters except for $ and ", and finally ' ' will escape all characters except for '. So if for example I have text with some single quotes ' in it, I can put " " around it to make it behave like a single text string. The problem I have is when my file contains both double and single quote characters. Then, I cannot use either type of quotes to escape it. So how do I ask bash to treat it as a single string?

Context: My iPhone's /var/mobile/Library/Safari/History.plist file. It contains something like:

  <key>
    <string>http://example.com/folder/index.html</string>
    <string>Title of Webpage which may include ' and "</string>
  </key>

I want to cat the file, pass it through grep to take the first line containing the text string and extract the URL from that. But grep chokes on all the quotes.

I know a fair bit about escape characters in BASH. I know that \ will escape the next character, " " will escape all characters except for $ and ", and finally ' ' will escape all characters except for '. So if for example I have text with some single quotes ' in it, I can put " " around it to make it behave like a single text string. The problem I have is when my file contains both double and single quote characters. Then, I cannot use either type of quotes to escape it. So how do I ask bash to treat it as a single string?

Context: My iPhone's /var/mobile/Library/Safari/History.plist file. It contains something like:

  <key>
    <string>http://example.com/folder/index.html</string>
    <string>Title of Webpage which may include ' and "</string>
  </key>

I want to cat the file, pass it through grep to take the first line containing the text string and extract the URL from that. But grep chokes on all the quotes.

Edit 1: Here are some screenshots of nano failing to read the file. Cat gives similar output. The graphical file editor iFile reads it as text. http://cloudrac3r.ddns.net/strange.html I am told this is what binary files do. I will do some experimenting.

formatting
Source Link
choroba
  • 49.7k
  • 7
  • 92
  • 119
Loading
Source Link
user171641
user171641
Loading