I want to replace a line with double quotes on OpenBox startup, like: with I use this command, but it does not work: It gives me this error: Answer The ampersand in the replacement string recalls the pattern in the search string. So you can just do this: Also, you can use single quotes on the outside, and double quotes
Tag: bash
Bash offer numberd results for selection to user
my script takes in a site name from the user. Its then allows the user to checkout, edit, and commit changes to the file, via the script. However, some sites have two to six files. So the script lists them as follows You have more than one Cambridge file. Please pick from the following: cambridge1 cambridge2 cambridge3 user enters the
how to replace [^u0009u000Au000Du0020-uD7FFuE000-uFFFDu10000-u10FFF]+ to “” in a file by sed or anything?
I find and replace some strange characters in xml file with text editor. with regular expression Now, I need to it in linux command line. I ask you how to use sed or anything that same find and replacement job in linux command line. Thank you in advance Answer You can try this : Before replacing, be sure you really
Linux – rename all files by replacing last hyphen with ‘##’
Please anyone. How do I in Linux rename a bunch of files like: abc-def-0001.xxx acb-def-0002.xxx to: abc-def##0001.xxx … I have tried several suggestions from SO like: rename ‘s/(.*)-/$1##/’ *.xxx But didn’t worked as expected in my environment. Answer So I ended up using: for i in *; do mv “$i” “`echo $i | sed “s/(.*)-/1##/”`”; done I think my version
Bash script to copy the directory structure from source directory into target directory
I am very new to Bash scritping and to get some practice, I am attempting to write a script that takes in a source directory and a destination directory. The script will search the source directory and copy its structure of sub-directories into the target directory (any files will be ignored, just the directories themselves will be duplicated). The source
How do I read the whole command line?
Command $ ls -l | ./main.out The output will show My question is, how do I make my program to read the command before that, ls -l Answer Command line parameters are passed as arguments when calling the program. And your program will read the entire command line arguments. But What you are doing ($ ls -l | ./main.out) is
formatting the output with sed command
I need your help… I got this kind of text: and the output I need is (first and second column and socialSecurityNumber OR tng-customer-id): So the question is … is it possible to solve this issue with sed command? I need the OR option here. If I try to do it separately, firstly, find the socialSecurityNumber, I get this: secondly,
Bash ssh for loop – env variable issue
When using a bash for loop and ssh’ing to multiple machines the hostname variable is not updated to be the name of the machine I’ve ssh’d into. What am I missing here? “A”, “B”, “C” are replaced with names of actual machines and the speech marks removed in the actual execution. In the example above $node is correctly outputted but
Search and replace file content using shell script
I want to search and replace specific value in a file, here is the content of the file I want to replace DocumentRoot /var/www/html with DocumentRoot /var/www/html/centos I tried the following This is not working, can someone point me to the right direction. Thanks Answer The line you are trying to replace is: It contains double-quotes. The sed command does
in Bash Script, how to read a file and split all lines into a two-dimensional array
Content of the file: How to read the file and split all lines into a two-dimensional array? like java. Like: thanks. Answer GNU bash has no two-dimensional array. A workaround is an associative array. See: help declare and man bash