0

I've seen an interesting question, mine is just the opposite.

I have a text file containing the following:

‍ ?Hadoop functions and tutorial?
https://abc. com/id=abc?33m?
 ? java function tutorial
https://abc .com/id=?bc?33m?

I've text file content below:

‍ ?Hadoop functions ?and tutorial
https://abc. com/id=abc?33m?
 ? java function tutorial
https://abc. com/id=?bc?33m?

I want to delete all the questions marks but they should not be removed from the lines containing https/http/HTTPS/HTTP.

I used following script below:

cat fi.txt |grep ^?|sed 's#?##g' >title.txt;cat fi.txt|grep ^https >url.txt;paste title.txt url.txt

Please help with opposite match function in sed or Awk (delete ? text but not from lines which contain https).

tripleee
  • 175,061
  • 34
  • 275
  • 318
  • Welcome on StackOverflow. May I suggest that you take a look at the [help center](https://stackoverflow.com/help) and especially at [How do I format my posts using Markdown or HTML?](https://stackoverflow.com/help/formatting)? – Renaud Pacalet Dec 16 '21 at 09:16
  • With GNU sed: `sed -E '/https?/I!s/\?//g' file`. With another sed: `sed -E '/(https?|HTTPS?)/!s/\?//g' file`. – Renaud Pacalet Dec 16 '21 at 09:21
  • I tried to clean up the formatting but this is still quite messy; please review. – tripleee Dec 16 '21 at 09:29

0 Answers0