I'm using Bash and Sed to replace text within a text file (1.txt) twice in one script. Using a for loop I'm initially replacing any 'apple' words with the variable 'word1' ("leg). I'm then using another for loop to replace any 'apple' words with the variable 'word2' ("arm"). This task is dependent on the text file 'resetting' it's contents back to it's original form prior to the second for loop; otherwise the second text changes cannot be made. My issue is, the text file does not reset; within the script it keeps the new text replacements.
Is there any way to reset the contents of the text file back to it's original content during a script? I am aware that the argument '-e' only temporarily changes a file's contents, but the file's contents only reset when a script has finished.
With a text file containing only one word 'apple', I expect the above script to replace the the word 'apple' with the word 'arm'. Only, for reasons described above, it is currently only changing to 'leg'.
Hi
I have the following file that i need to run a sed command on
1<tab>running
2<tab>running
3<tab>running
4<tab>running
I want to be able to replace a line i.e the second one with '2<tab>failed'. As the first number is unique that can be used to search for the relevant line (using ^2 i... (5 Replies)
Hi group,
I want to replace the occurance of a particular text in a paragraph.I tried with Sed,but Sed only displays the result on the screen.How can i update the changes in the original file???
The solution should be a one liner using awk and sed.
Thanks in advance. (5 Replies)
Hi
Can anyone provide me the replacement of sed with xargs perl syntax for the below
sed -e :a -e '/;$/!N;s/\n//; ta' -e 's/;$//'
This should be without looping has to take minimal time for search (0 Replies)
Hi,
Im trying to find and replace text within a unix file using sed.
The command that i have been using is
sed '/,null,/ s//, ,/g' result.txt>result.tmp
for replacing ",null," with ", ,".
But this only replaces the first occurrance of ,null, in every line. I want to do it globally.
It... (7 Replies)
This seems like it should be an easy problem, but I'm a noob and I can't figure it out. I'm trying to use sed, but would be happy to use anything that does the job.
I am trying to trim off a fixed number of unknown characters from 2 different : delimited fields while keeping the intervening... (4 Replies)
I am trying to replace the line which has string "tablespace" not case senstive....
with below simple script: mysrcipt.sh
sed "s/.*/TABLESPACE USERS/g" create_table > tmp
mv tmp create_table
Is there any better way to do it? If Search string tooooooo long it will be tough to code in... (4 Replies)
Hi,
i have a file with lines,
file.txt
-------
test is fun
testing is better
I need to replace 'test' to 'develop' and i used,
a=test
b=develop
sed "s,$a,$b,g" -------- but i see the word 'testing' is also replaced. Need some solution. Is there any way i could replace only 'test' ? (4 Replies)
Hi,
I have a requirement in which i need to replace text as below -
<stringProp name="Recipe"><AddGroup Name="1001" Path="ServiceAdministration/Controls/1001/ServiceSwitches">
<Param Name="AttributeName" Value="HeaderManipRspIngressRuleSet" Type="String" />
<Param Name="Value"... (0 Replies)
Hi guys,
I worked for almost a half-day for the replacement of some text automatically with script. But no success.
The problem is I have hundred of files, which need to be replaced with some new text. It's a painful work to work manually and it's so easy to do it wrong.
For example,
I... (2 Replies)
Hi all,
Saying we have two files:
1. A "Reference File" whose content is "Variable Name": "Variable Value"
2. A "Model File" whose content is a model program in which I want to substitute "VariableName" with their respective value to produce a third file "Program File" which would be a... (4 Replies)
Discussion started by: dae
4 Replies
LEARN ABOUT DEBIAN
rpl
RPL(1) BSD General Commands Manual RPL(1)NAME
rpl -- replace strings in files
SYNOPSIS
rpl [-LhiwbqvsRepfdt] [-xSUFFIX] <old_string> <new_string> <target_file ...>
DESCRIPTION
Basic usage is to specify two strings and one or more filenames or directories on the command line. The first string is the string to
replace, and the second string is the replacement string.
-h, --help
A short help text.
-L, --license
Show the license and exit.
-xSUFFIX
Search only files ending with SUFFIX, e.g. ``.txt''. May be specified multiple times.
-i, --ignore-case
Ignore the case of old_string.
-w, --whole-words
Make old_string match only on word boundaries.
-b, --backup
Move the original files to filename~ before replacing them.
-q, --quiet
Quiet mode.
-v, --verbose
Verbose mode.
-s, --dry-run
Simulation mode, no files are changed.
-R, --recursive
Recurse into subdirectories.
-e, --escape
Expand escape sequences in old_string and new_string. Examples of escape sequences are '
' (new-line), ' ' (tab), 'x42' (hexadec-
imal number 42), '