Linked Questions

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) ...
0
votes
1answer
139 views

Substituting words in parenthesis using sed [duplicate]

I have a basic python script that looks like this: my_name = 'Zed' my_age = 35 my_height = 74 my_weight = 180 my_eyes = 'Blue' my_teeth = 'White' my_hair = 'Brown' print "let's talk about %s" % ...
0
votes
1answer
645 views

Why won't my change to the sshd_config file persist? [duplicate]

I am writing a script to modify settings on my Ubuntu server. I have the following line in it: sudo sed 's/PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config The problem is ...
0
votes
1answer
805 views

Modify part of line if keyword is found using sed? [duplicate]

I want to modify a line if a specific keyword is found in a line. CS_CODE, SM_NUM, PORT_NUM, DEV_PORT_NUM, DIRNUM, MAIN_DIRNUM, BILL_NO, ADR_NAME In above line, if 'PORT_NUM' is present then '...
0
votes
1answer
2k views

How to change a single line in multiple files [duplicate]

I have ~750 .php files in the same directory that contain the line include("path/to/file.php"); I would like to change this line in every file to require_once("path/to/file.php"); What would be an ...
0
votes
1answer
102 views

Replace copyrights recursively [duplicate]

I have many files under the current directory. Each file contains copyrights headers like, # # Copyright 2013 Company, Inc. All rights reserved. This software # is property of Company, ...
-1
votes
1answer
124 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 ...
-1
votes
1answer
751 views

How do i create a sed script to prompt the user to replace a number in a file? [duplicate]

I'm new in Unix, and I'm learning about sed command. I need to write a very small script for searching a number in a file and replacing it. I tried doing grep, and than deleting the specific phone ...
-1
votes
1answer
1k views

How to edit a file from a script using a loop instead of find and replace with sed? [duplicate]

Here is an example of what I am trying to do: #!/bin/bash Update=$1 if [$Update == Value] then NewValue= $Update vi %s/Value/$NewValue/g > Updatedfile fi exit 0 Is there a way to ...
-1
votes
1answer
208 views

Replace mutiple strings with different values in a file using unix [duplicate]

I have a file in which the data is like below, 01,0000000,xxxxxxx/ 02,xxxxxxxx,yyyyyy/ 03,test1,41203016,,/ 01,0000000,xxxxxxx/ ...
-1
votes
1answer
5k views

how to replace a specific pattern from all files [duplicate]

suppose I want to replace abc with xyz in all files in a directory. How do I write a script for this ?
-2
votes
1answer
41 views

How do I convert all occurrences of the word “OLD” in some file with the word “NEW” in Linux [duplicate]

Can someone give me a command that convert all occurrences of the word “OLD” in some file with the word “NEW” in Linux? Thanks in advance
-3
votes
1answer
3k views

How can i replace a specific string within a line inside a text file [duplicate]

$ cat text.txt my name is Steven my age is 10 i like dogs What command will be fitting so that echo "Kate" will replace Steven on text.txt?
-4
votes
1answer
3k views

How to change certain word in certain line in a file [duplicate]

i have a file in which i have to change a word and then save it by same name. for ex- for file "name"- my name is joe (original data) my name is roy (changed data) how to do it in best possible ...
1
vote
0answers
175 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?

15 30 50 per page