Linked Questions

0
votes
2answers
52 views

Remove occurrence of a pattern from string everywhere [duplicate]

I want to remove occurrence of a string from a given string. Like /hello: from a string like /yo:/sup:/hello:/yo:/hello:/yup. And one thing for sure if string contains a colon in end then it must be ...
-1
votes
2answers
806 views

How to use sed on all matching files?

I am trying to run sed on the output from find | grep \.ext$ However, sed requires input file and output file. How can I save the output line to a variable, or pass it to sed?
1
vote
1answer
786 views

Grep global find replace [duplicate]

Is there a way to grep for a regular expression on an Ubuntu server and then find and replace it with another string? I am using the following command right now, but it doesn't account for actually ...
0
votes
1answer
214 views

Search and replace something contained in ' (single quotes)

In various files in lots of sub folders I have the following text in large text files, each unique Linux.Secret = 'XYZZYXZYXZYXZYXZYXZ' I would like to make it so all the Linux.Secret = '' are the ...
0
votes
2answers
150 views

Insert character at the beginning of specific lines [duplicate]

Let's say I have file: % This is first line % This is second line This is content % This is the end How can I insert a % character at the beginning of every line which already starts with %? ...
0
votes
1answer
194 views

Running several sed commands on same files simultaneously

To change all occurences of the string foo to bar in all files in a directory I use sed -i -- 's/foo/bar/g' * Found that here But I also want to change NAME to name etc. I tried, sed -i -- 's/foo/...
1
vote
1answer
300 views

Inserting delimiter into file

I have a file with a similar format to the following: 1.1.1.5 Ensure mounting of hfsplus filesystems is disabled 1.1.1.6 Ensure mounting of squashfs filesystems is disabled 1.1.15 Ensure nodev option ...
1
vote
0answers
174 views

Search For a Word and Replace It In Entire File Using Egrep [duplicate]

How do I search an entire file for a word and replace it with another word using egrep?
2
votes
1answer
162 views

What does **/*(D.) mean in (zsh) sed arguments?

I see this command being given as how to search and replace strings in files in this answer: sed -i -- 's/foo/bar/g' **/*(D.) What does the pattern */*(D) mean? I am not sure what they are called, ...
0
votes
1answer
3k views

How to replace the last octet of a valid network address with the number 2 [duplicate]

Lets say I have a string that can be any possible/valid network address like so: STR="192.168.1.0/24" What I want to do is replace the last octet (in this case it's 0/24, however it can be anyting) ...
6
votes
3answers
11k views

How to delete all occurrences of a list of words from a text file?

I have a file containing a list of words. I want to remove all occurrences of all the words in this file from a big text file. Example: File 1 queen king Text file sample Both the king and queen ...
4
votes
4answers
203 views

Double quote value assignments stored in a CSV?

I have a file that contains text as follows: dt=2016-06-30,path=path1,site=US,mobile=1 dt=2016-06-21,path=path2,site=UK,mobile=0 I want to convert it to text with double-quoted values in the key-...
0
votes
3answers
101 views

How to modify file content? [duplicate]

Ubuntu 16.04 I have some pretty large file so modifying it by hand is not possible. I'd like to change all occurences of <tag1>true</tag1> to <tag1>false</tag1>
-1
votes
1answer
120 views

Replace a value in a file, in a certain context, with an operation result

I have an array of JSON object with inside local urls and speed parameters like [{server:"192.168.0.100", speed:34}, {server:"192.168.0.130", speed:52},...] I need to update the speed value for each ...
3
votes
2answers
365 views

How do I delete a line only if it is at the specified line number and it matches the pattern? [duplicate]

How do I delete a line only if it is at a specified line number and it matches the pattern? For example: I want to delete (d); the third line (3); if it's blank (^$); The following syntax: cat ...

15 30 50 per page