Linked Questions

6
votes
3answers
10k views

How to escape single quotes correctly creating an alias [duplicate]

I've been given this one-liner to know how much memory my processes consume. $ ps -u $USER -o pid,rss,command | \ awk '{print $0}{sum+=$2} END {print "Total", sum/1024, "MB"}' Now I'd like to ...
3
votes
2answers
12k 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 ...
4
votes
4answers
7k views

How to substitute 'single' apostrophes to “double” apostrophes with sed [duplicate]

trying to substitute single apostrophes to doubles. But cant get it right. sed 's/'/"/'
2
votes
2answers
1k views

Grep syntax error with correct regex [duplicate]

I've created a regex which I need to run with grep, I'm pretty sure the regex is fine as it works with online regex tools, however when I run grep -r -P -o -h '(?<=(?<!def )my_method )(["'])(?:...
2
votes
3answers
3k views

Replace text using sed and also add single quote to it [duplicate]

I answered this question, but I am stuck on the part where I have to add a single quote also to it. Like original file is: $$BATCHCTRL=TEST-012017 $$STATE=CA AZ $$FROM_DATE=01/10/2017 $$TO_DATE=01/...
0
votes
2answers
4k views

Putting a single quote in a filename [duplicate]

We can a make a directory named $"dollars"&<>\dogs if we surround it with single quotes like the following mkdir '$"dollars"&<>\dogs' However, what if I want to include a single ...
1
vote
1answer
776 views

Is there a way to use apostrophes in sed commands? [duplicate]

Is there a way to use apostrophes ' with the sed command? I mean this: - sed '-2 a\\ What's up?' text I am talking about the apostrophe in "What's up". If I do it like this it gives me an ...
0
votes
3answers
709 views

Escaping single quotes **with** an alias [duplicate]

I am aware that there are many questions asked in the past about escaping single quotes, but none of them addresses this challenge, i.e how to do it with an alias. I have already successfully defined ...
1
vote
2answers
191 views

how to set alias of command in bash that contains both single and double qoutes [duplicate]

I am not able to set alias of hexdump -e '/1 "%_ax) "' -e '/1 "%02X" "\n"' I have tried following methods but failed: alias analyze=\'hexdump -e '/1 "%_ax) "' -e '/1 "%02X" "\n"'\' (note the first ...
0
votes
2answers
204 views

Can't delete with sed [duplicate]

I have this text in /etc/bash.bashrc: alias dwa='bash /opt/dwa.sh' I tried to delete it with the following (and similar commands): sed -i 'alias dwa=\'bash /opt/dwa.sh\'/d' /etc/bash.bashrc Why ...
0
votes
1answer
72 views

how to echo some unique character [duplicate]

I want to echo some unique string to a file. Sample code like bellow: { echo " LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined" echo " LogFormat "%h %l %u %t \"...
0
votes
1answer
48 views

complicated command replace in files using sed [duplicate]

I want to replace the below strings replace: print 'Status Code: {code}'.format(code=r.status_code) with: print('Status Code: {code}'.format(code=r.status_code)) Here is the command I ran which ...
8
votes
7answers
606 views

Bash awk command with quotes

I have been trying to find the answer to this question for a while. I am writing a quick script to run a command based on output from awk. ID_minimum=1000 for f in /etc/passwd; do awk -F: -vID=$...