A simple find and replace without using any regex (bash)
Hi,
I need to do an exact find and replace (I don't want to use regular expressions because the input comes from user). I want to find a line that matches the user's input text and replace it with an empty string.
For example, let's say the user enters I love "Unix" and the contents of the file where I want to do find and replace is this:
Now I want to replace the line I love "Unix" with empty string. And I want to leave the remaining lines like I said I love "Unix" and I love "Unix" a lot as is. The double-quotes are intentional.
Which Unix utility can do this? An example would be great! I searched and found that sed is something close what I am looking for, but it takes a regular expression. Because the input string is coming from the user, it's tough for me to generate a regular expression for that. Any other ways?
I have got a question. How to do this? I mean AND expression in regex.
List all the files in current directory that do not contain the words use AND take.
Thx.:p (15 Replies)
here is my prob ..
i have a very large text files and i need to locate specific lines, copy them and then replace a single word in the replaced text
example
find all lines that contain '/etc', copy the line immediately below (not at the end of the file) and then replace '/etc' with '/root'... (1 Reply)
Hi all,
I am looking to create words from a sentence which adhere to a custom search pattern from my website:
Example:
! +! / += ~
where the terms ! = not, +! = AND NOT, += - and equals and ~ = can be like....
Now here is the issue...i want to split a sentence like the one above on... (1 Reply)
Hi,
I am trying to write a script which will modify a given account's settings by searching for a line in a file and then replacing the line after it. Here is a portion of my input file:
type=friend
username=0002
secret=password
host=dynamic
dtmfmode=rfc2833
mailbox=0002
context=sip... (2 Replies)
I am trying to write a find and replace script with AWK and I can't seem to get it to work. I need it to find this exact string *P*: and replace the P with a T or just replcare the whole thing with *T*:.
this is what I have tried
awk 'BEGIN {gsub(/\*P*:/,"\*T*:"); print}' ${INFILE} >... (4 Replies)
Hello,
I am trying to grep my log files for ORA errors, except ORA-00001.
I have tried:
grep 'ORA*!(-00001)' *.log
but it is not working.
Any help will be much appreciated.
Thank you. (5 Replies)
I am trying to grep the following line in a file using a bash shell:
(..)
admin1::14959::::::
(..)
It works with the following expression (as expected)
# cat file | grep ^*::
admin1::14959::::::
but it does not work with (not expected)
# cat /etc/shadow | grep ^+::
I assume the... (2 Replies)
Hi!
I'm looking for a simple script, especially a one liner script in tcsh or bash
that will emulate the find/replace in all text apps.
I want to change all uppercase caracters to Title word (in wich only the first caracter is UpperCase and the rest is lowercase)
I can use sed command, but... (2 Replies)
Hello all!
This is my first post and I'm very new to programming. I would like help creating a simple perl or bash script that I will be using in my work as a junior bioinformatician.
Essentially, I would like to take a tab-delimted or .csv text with 3 columns and write them to a "3D" matrix:
... (16 Replies)
Hi !
Before trying to write a code, is there any program or code that generates all the combinations of strings that simple awk regex can match.
By "simple regex" I mean let's say without "+", "*", and with a limited number of characters (e.g. from "1" to "5").
e.g:
input:
34?5
output:... (9 Replies)
Discussion started by: beca123456
9 Replies
LEARN ABOUT REDHAT
replace
REPLACE(1) General Commands Manual REPLACE(1)NAME
replace - A utility program that is used by msql2mysql, but that has more general applicability as well. replace changes strings in place
in files or on the standard input. Uses a finite state machine to match longer strings first. Can be used to swap strings.
USAGE
replace [-?svIV] from to from to ... -- [files]
or
replace [-?svIV] from to from to ... < fromfile > tofile
SYNOPSIS
replace [-?|-I] [-s] [-v]
DESCRIPTION
replace
-?|-I info
-s silent
-v verbose
EXTRA INFO
Special characters in from string:
^ Match start of line.
$ Match end of line.
Match space-character, start of line or end of line. For a end the next replace starts locking at the end space-character. A
alone in a string matches only a space-character.
EXAMPLE
this command swaps a and b in the given files:
shell> replace a b b a -- file1 file2 ...
SEE ALSO
isamchk (1), isamlog (1), mysqlaccess (1), mysqladmin (1), mysqlbug (1), mysqld (1), mysqldump (1), mysqlshow (1), msql2mysql (1), perror
(1), replace (1), safe_mysqld (1), which1 (1), zap (1),
AUTHOR
Ver 1.0, distribution 3.23.29a Michael (Monty) Widenius (monty@tcx.se), TCX Datakonsult AB (http://www.tcx.se). This software comes with
no warranty. Manual page by L. (Kill-9) Pedersen (kill-9@kill-9.dk), Mercurmedia Data Model Architect / system developer (http://www.mer-
curmedia.com)
20 December 2000 REPLACE(1)