All Questions
Tagged with replace shell-script
33 questions
0
votes
2
answers
350
views
Merge two two-column files based on a common first column prefering values from the second column of a given file
I have two text files 1.txt and 2.txt that contain two tab separated columns. The first column of both files consists of tokenized text. In both files, the first column is the same. The word order ...
2
votes
3
answers
609
views
Sed replace the middle string
I have this this String
22<>22
And i have this list
test
dev
too
The output should be like
22test22
22dev22
etc..
This is the commands i use for do that
cat list | sed 's/$/22/g' | sed 's/^/...
0
votes
2
answers
266
views
sed and awk in sh script not replacing text
The desired work to find a string, and replace to another (all occurrencies), and rewrite/update the file too.
The file is an pbxproj file. I linked a sample of this file
sample of the file (please ...
0
votes
1
answer
212
views
How can I replace a word with another word in a whole hierarchy of files
I have a hierarchy of files and two words: word1 and word2.
In this hierarchy of files, some of them can contain word1. I want to replace every occurrence of word1 with word2. It is possible using a ...
2
votes
2
answers
5k
views
Alternative to sed -i that does not write temporary files
I have several scripts that edit template text files, by removing a "tag" and replacing it with e.g. a number. To do this I use the
sed -i
command. However, I have an issue with write/read ...
1
vote
1
answer
271
views
Text processing with sed on a variable in bash not giving expected (modified) output?
We are using some outdated encoded script which does not to be allowed to be modified. Therefor I though of a solution to modify the input automatically by using sed. This didn't work and after ...
0
votes
1
answer
824
views
Replacing the multiple values from a string with the values of file in bash
I have one sql file on which I'm doing cat and assigning to a variable say "SQL". I have different DATABASES and different TABLES in sql file. I'm trying to replace those tables and databases value ...
0
votes
1
answer
2k
views
Simple Binary Replacement
I tried using bbe as below
bbe -e 's/01110011/01111000/' test.txt
All I'm trying to accomplish in this example is to read the file as if it's a binary file, and replacing the letter s with x.
I'm ...
0
votes
2
answers
82
views
Storage disk info - Replace multiple Input values to output file
I would like replace below input about storage disk to an output in below presented format:
Below script is almost working for me. But it doesn't work for T0.
It seems is there problem with proper ...
1
vote
0
answers
62
views
Two replacements in one go [duplicate]
How do I go about replacing one character for another and then another character for another in one line and printing the result?
As an example, consider the following code:
string="1 33 4 a"
echo ${...
0
votes
3
answers
115
views
How to replace a number by its corresponding string (low/high) in bash?
I have a file:
property(Address1, 4.5)
property(Address2, 2.2)
property(Address3, 9.0)
property(Address4, 3.4)
---
I want to replace the floating points based on some conditions (For example: if the ...
6
votes
1
answer
3k
views
A posix-compliant function for replace text with parameters and regex
I'm making a function with a replacement of strings using regular expressions in a secure way, without possibility to inject characters, and without renouncing the use of regular expressions:
#! /bin/...
0
votes
5
answers
5k
views
how to change last value (ip address) with sed
I read the current ip address with following command line. after then i need to replace the last value with 0/24
For example. The current ip ist 192.168.178.1 and i need to replace the var value in ...
-2
votes
1
answer
2k
views
Replace a string with sentence containing multiple newline characters [duplicate]
I am trying to replace string with a sentence or paragraph contacting multiple newline characters using shell script. Replacement string will be generated run-time.
eg:
sed /string_to_be_replaced/...
0
votes
2
answers
116
views
How to use sed to replace strings with categories?
I have some categories and their values:
Category: Value:
1*4 15.934934
1*5*3 19.281281
1*8*10*2 78.20912
I would like to replace the categories by numbers that represent the ...