0
votes
1answer
29 views

replacing subString in an Array BASH

what i got: array[0]="Programm is Running" array[1]="programm is down" what i want: array[0]="Programm is \e[0;32mRunning\e[0m" array[1]="programm is \e[0;31mDown\e[0m" this will make things a ...
0
votes
3answers
57 views

How do I exclude match and change only specific character with sed

I am trying to use sed to replace '0' with the word 'correct' (I am using echo $? to validate my script and I want to replace the output of echo). The problem is that I have more text in the output ...
1
vote
2answers
129 views

replace file's content between specific line numbers with another file using BASH

What is the most efficient way to replace file's content between specific line numbers with another file? Here is a sample: main.txt: a b c d e f g h i j k l new.part.txt x y z p q r s t u The ...
4
votes
3answers
100 views

change the first word of the previous command

For example I enter cat /very/long/path/textfile and right after that I decide to give the next command rm /very/long/path/textfile So, my question is: What is the easiest/fastest way to replace ...
2
votes
2answers
261 views

sed in bash not working

I am trying to use the stream editor sed in bash to replace a string in a file to a new string that I entered, I have this thus far: echo "name to change" read updatenaamold echo "enter new name:" ...
5
votes
3answers
1k views

Am I using sed properly to perform this conditional replace? Is there a better way?

I have a space-delimited file that's about 3200 lines long. Each line contains 7+ fields. What I would like to do is edit the file with sed so that every line containing a certain variable in field 5 ...
1
vote
4answers
4k views

How do I substitute environment variables when I ouput a file?

I'd like to somehow spit out a file (which has env variable references) and substitute the actual values. This is what I've tried, but as you can see it's not working. Any ideas? -bash-3.00$ cat ...