All Questions
42 questions
3
votes
5
answers
645
views
removing braces statements containing nested braces inside
A typical latex problem:
\SomeStyle{\otherstyle{this is the \textit{nested part} some more text...}}
Now I want to remove all \SomeStyle{...} but not the content. Content contains nested braces. The ...
3
votes
2
answers
4k
views
How to substitute non printable characters with space character in a file
I have read nearly every answer about this topic on this website or Stackoverflow but didn't manage to solve the issue below.
When I copy the text from a PDF file and paste it into a text file file....
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
2
answers
940
views
Replace several consecutive lines with a single line using sed
In all my python scripts, I'd like to replace the 2 consecutive lines
import matplotlib as mpl
mpl.style.use(mpl_plt_default_template)
with just the line
plt.style.use(mpl_plt_default_template)
So ...
3
votes
6
answers
3k
views
Using sed to replace substrings between specific tags
I want to combine two sed command in one and really don't know how to do it, I've tried multiple things without success.
For the result I want all slash between a specific tag to be replaced with ...
-3
votes
1
answer
49
views
Replace a string using the same word from other file
I'm looking to edit my 1.txt file, to find a word and replace it with the corresponding word in 2.txt and also add the rest of the string of 2.txt.
I'm interested in maintaining the order of my 1.txt ...
2
votes
1
answer
2k
views
Insert a line at specific position if file contains a certain string
I would like to insert a string in line 2 of every file that contain a specific string somewhere in the file.
Like
sed '1 a #This is just a commented line' -i
but only if file contains the string:
...
2
votes
2
answers
527
views
Bash replace string at multiple places in a file from command line
I have a file with the below content. I want to replace chrome with chromeBackup but not in all places.
Name=chrome
XXXXXXXXXXX
Run=bin -app "chrome/chrome.sh"
XXXXXXXXXXX
Vol.apps/chrome=chrome
...
0
votes
2
answers
52
views
How do I use different replacement texts for a pattern found multiple times [duplicate]
sample log file:
apple AAA rose
banana AAA tulip
orange AAA marigold
replacement-text file:
111
222
333
Expected output:
apple 111 rose
banana 222 tulip
orange 333 marigold
2
votes
3
answers
585
views
Conditionally replace lines of file1 with the corresponding lines of file2
For example, I have two files:
file1:
1
4
X
5
X
7
file2:
2
3
5
X
X
1
I want to replace X-lines of file1 with whatever is in file2 on the corresponding line:
result:
1
4
5
5
X
7
I prefer the ...
1
vote
2
answers
2k
views
Bash replace string with command
I have a command (logcat) which outputs a long log like this:
07-27 09:26:22.416 17574 17886 D SurfaceControl: Excessive delay in setPowerMode()
07-27 09:26:22.421 17574 17599 I PowerManagerService: ...
1
vote
4
answers
227
views
Replace text with values
I have two files that need to be merged into one.
File 1 example:
gene_1 578
gene_2 565
gene_3 3
gene_4 77
gene_5 8
gene_6 0
gene_7 45
gene_8 67
gene_9 0
gene_10 65
File2 example:
COG0430 ...
1
vote
2
answers
234
views
Find and Replace Duplicates
I have a file with concatenated emails in it that looks like the following:
id emails
1 [email protected]
2 [email protected]
3 [email protected],[email protected],[email protected]
Each row only has ...
4
votes
3
answers
3k
views
Ignore part of the string with sed
so, I have files with text formatted like this:
untranslatedString : "translated string",
and I need to replace characters in "translated string" part with their Cyrillic representation. I use ...
1
vote
4
answers
224
views
Script to replace last slash in the mount point
I'm trying to do a script to delete the last "/" in the mount point inside of the fstab.
I create this shell script, but, I'm not happy with the result. I wonder if anyone knows how to replace with ...