Skip to content
Advertisement

Tag: escaping

what alternative methods for sudo echo without bash -c

I must run the echo in the script my.sh with sudo because permission. I do not want to execute the script with sudo my.sh. I do not want to use bash -c “…” because escaping. Are there no other solutions? my.sh Answer The problem you are encountering here is that the output redirection >/file.tmp has to happen with elevated privileges.

Bash escape character

I have this very reduced example of a bash command, where I want the $ sign escaped. So the command : should print out: a simple $test does not work unfortunately. I tried lots of other stuff but still couldn’t find a solution. Any suggestions ? Answer Put it in single quotes rather than double quotes. The single quotes keep

Sed with special caracters

How can I replace this with sed ? I need to replace this: to Please note that I can’t sed the enabled to disabled because it’s not only used at this location in the input file. I tried this but it didn’t change anything but gave me no error: Answer You can just use the following sed command: CMD: Explanations:

How to escape java special characters and run Linux commands

I’m writing a java program to find specific files(files with special permissions and by file type) within the directory. The following command executes properly since there aren’t any special characters. Now if i try to execute the following command using my java program, terminal doesn’t give a proper result. Java Program, Program works fine.however, String cmd command doesn’t give me

Using a shell commands in c++

Here’s a terminal command: Here’s my code: The above code, when run, returns this message: How can I place the ‘/’ symbol, for this command to work correctly? Answer Your problem is not in C++. You are invoking your command with popen, and popen runs your command in sh shell, that does not support <() syntax, while in your terminal

Is space considered a metacharacter in Bash?

I have searched for the list of metacharacters in Bash but space is not enlisted. I wonder if I’m right by assuming that space is the “token separation character” in Bash, since it not only works as such with Shell programs or builtins but also when creating an array through compound assignment – quotes escape spaces, just like they do

Advertisement