I have this string:
mystring = 'Here is some text I wrote '
How can I substitute the double, triple (...) whitespace chracters with a single space, so that I get:
mystring = 'Here is some text I wrote'
I have a string with multiple commas, and the string replace method will only change the first one:
var mystring = "this,is,a,test"
mystring.replace(",","newchar", -1)
Result: "thisnewcharis,a,test"
The documentation indicates that the default…
#!/bin/bash
jobname="job_201312161447_0003"
jobname_pre=${jobname:0:16}
jobname_post=${jobname:17}
This bash script gives me Bad substitution error on ubuntu. Any help will be highly appreciated.
What's the preferred way to do command substitution in bash?
I've always done it like this:
echo "Hello, `whoami`."
But recently, I've often seen it written like this:
echo "Hello, $(whoami)."
What's the preferred syntax, and why? Or are they…
I run several substitution commands as the core of a colorize script for maven.
One of the sed commands uses a regular expression which works find in the shell as discussed here. The current (not working) implementation can be found here.
When I…
I'm trying to create a script file using substitution string from ENV but want also to prevent some from escaping
export PLACEHOLDER1="myPlaceholder1Value"
sudo /bin/su -c "cat << EOF >…
I am trying to change the values in a text file using sed in a Bash script with the line,
sed 's/draw($prev_number;n_)/draw($number;n_)/g' file.txt > tmp
This will be in a for loop. Why is it not working?
I'm using Vim, and I want to substitute some placeholder text with a long string, that spans several lines, which is already written somewhere else in the file.
Is it possible to replace a pattern with the contents of a register? Something…
I'm trying to remove all newline characters from a string. I've read up on how to do it, but it seems that I for some reason am unable to do so. Here is step by step what I am doing:
string1 = "Hello \n World"
string2 = string1.strip('\n')
print…
I would like to do the following:
$find = "start (.*) end";
$replace = "foo \1 bar";
$var = "start middle end";
$var =~ s/$find/$replace/;
I would expect $var to contain "foo middle bar", but it does not work. Neither does:
$replace = 'foo \1…
I've always used an interface based git client (smartGit) and thus don't have much experience with the git console.
However, I now face the need to substitute a string in all .txt files from history (so, not erasing the whole file but just…
I am trying to understand the "cdargs-bash.sh" script with cdargs packages. And I have a question about in the following function:
function _cdargs_get_dir ()
{
local bookmark extrapath
# if there is one exact match (possibly with extra path info…
In Unix the ^ allows you to repeat a command with some text substituted for new text. For example:
csh% grep "stuff" file1 >> Results
grep "stuff" file1
csh% ^file1^file2^
grep "stuff" file2
csh%
Is there a Vim equivalent? There are a lot of times…
I have a line of code that works fine in my terminal:
for i in *.mp4; do echo ffmpeg -i "$i" "${i/.mp4/.mp3}"; done
Then I put the exact same line of code in a script myscript.sh:
#!/bin/sh
for i in *.mp4; do echo ffmpeg -i "$i" "${i/.mp4/.mp3}";…