Skip to main content

All Questions

1 vote
1 answer
435 views

How to insert ESC control characters in a file in FreeBSD?

I want to enclose Fortran comments with two escape commands (ESC+E and ESC+F). This implies detecting the comment that begins with ! until end of line, and prefixing it with ESC+E and suffixing it ...
M.E.'s user avatar
  • 609
1 vote
1 answer
2k views

Convert JSON with raw characters in string

Had a problem with a tool that was generating illegal JSON. Some of the JSON strings contained characters in the range 00-1f. So I wanted to convert these characters to correctly escaped valued \...
Loki Astari's user avatar
4 votes
4 answers
18k views

Bash converting path names for sed so they escape [duplicate]

I'm having a problem with a script. It is meant to change a value in a file called %DIR% so that it becomes a path name. The problem is the slashes in the directory name upset sed, so I get weird ...
John Tate's user avatar
  • 1,990
2 votes
1 answer
1k views

How do I properly escape this long su + sed command?

#!/bin/bash wineuser=tom su $wineuser -c "sed -i '$ialias ptgui "wine ~/.wine/drive_c/Program\ Files/PTGui/PTGui.exe\"' /usr/people/$wineuser/config/cshrc.csh" The acutal line inserted to tom's cshrc....
Party Time's user avatar
5 votes
2 answers
20k views

How to escape a single quote? [duplicate]

This works fine: sed -i 's# @driver.find_element(:xpath, "//a\[contains(@href,##' temp_spec.rb against a source of @driver.find_element(:xpath, "//a[contains(@href,'change_district')]").click I ...
Michael Durrant's user avatar