04-25-2008
How to search and replace text in same file
script is as below
v_process_run=5
typeset -i p_cnt=0
pdata=/home/proc_data.log
while [ $p_cnt -le $v_process_run ]
do
# execute script in background
dummy_test.sh "a1" "a2" &
p_cnt=$p_cnt+1
echo "data : $p_cnt : Y" >> $pdata
done
file created with following data in /home/proc_data.log
data : 1 : Y
data : 2 : Y
data : 3 : Y
data : 4 : Y
data : 5 : Y
now when each background process is completed
want to delete the line for matching pattern from log file without redirecting to new file ( below command is not working , please suggest)
for example :
grep "data : 3 : Y" /home/proc_data.log | sed "/data : 3 : Y/d"
or
now when each background process is completed
want to update the line for that process from log file
without redirecting to new file ( please suggest);
search for : data : 3 : Y
and relace with : data : 3 : N
hence output in the file should be
data : 1 : Y
data : 2 : Y
data : 3 : N
data : 4 : Y
data : 5 : Y
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi, I am trying something like this: Let's say I have a file called File1 with contents:
x=-0.3
y=2.1
z=9.0
I have another file, File2, with contents:
xx=
yy=
zz=
(nothing after "="). What I want to do is get the value of x in File1 and set it to xx in File2, i.e., xx=-0.3. And the... (3 Replies)
Discussion started by: ommatidia
3 Replies
2. UNIX for Dummies Questions & Answers
I have a text file with following content (3 lines)
filename : output.txt
first line:12/12/2008
second line:12/12/2008
third line:Y
I would like to know how we can replace 'Y' with 'N' in the 3rd line keeping 1st and 2nd lines same as what it was before.
I tried using cat output.txt... (4 Replies)
Discussion started by: santosham
4 Replies
3. UNIX for Dummies Questions & Answers
i am very new to UNIX
plz help me in this scenario
i have two text files as below
file1.txt
name=Rajakumar.
Discipline=Electronics and communication.
Designation=software Engineer.
file2.txt
name=Kannan.
Discipline=Mechanical.
Designation=CADD Design Engineer.
... (6 Replies)
Discussion started by: kkraja
6 Replies
4. Shell Programming and Scripting
Hi all,
I have a requirement where i have to search data between strings 'SELECT' and ';' and replace this text as "SELECT.....;" so that i can export this extracted string into a excel cell.
Please suggest on this. (5 Replies)
Discussion started by: goutam_igate
5 Replies
5. Shell Programming and Scripting
hello all
greeting for the day
i have a text file as the following
text.xml
abcd<FIELD>123.456</FIELD>efgh
i need to replace the value between <FIELD> and </FIELD> by using awk command.
please throw some light on this.
thank you very very much
Erik (5 Replies)
Discussion started by: erikshek
5 Replies
6. Shell Programming and Scripting
Hi There...
I need to serach and replace a strings in a text file.
My file has; books.amazon='Let me read' and the output needed is
books.amazon=NONFOUND
pls if anybody know this can be done in script sed or awk.. i have a list of different strings to be repced by NONFOUND.... (7 Replies)
Discussion started by: Hiano
7 Replies
7. Emergency UNIX and Linux Support
Hi,
I have gigabytes of text files that I need to search for "&" and replace with "&". Is there a way to do this efficiently (like sed command)?
Hope you could help.
Thanks. (17 Replies)
Discussion started by: daytripper1021
17 Replies
8. Shell Programming and Scripting
Hi
I am new to unix and newbie to this forum. I need help in writing a gawk script that search and replace particular text in a flat file.
Input file text :
ZIDE_CONTROL000 100000000003869920900000300000001ISYNC 000002225489 0000000002232122 20120321 16:40:53
ZIDE_RECORD000... (5 Replies)
Discussion started by: gkausmel
5 Replies
9. Shell Programming and Scripting
Hello,
Some time ago a helpful awk file was provided on the forum which I give below:
NR==FNR{A=$0;next}{for(j in A){split(A,P,"=");for(i=1;i<=NF;i++){if($i==P){$i=P}}}}1
While it works beautifully on English and Latin characters i.e. within the ASCII range of 127, the moment a character beyond... (6 Replies)
Discussion started by: gimley
6 Replies
10. Shell Programming and Scripting
Hi there,
First of all this is my first post here. Thank you in advance for your help.
What I am trying to do is the following. I have a text file where each field of each row is separated by a tabulator.
Looks like this:
ATOM 1 N HSE A 26 3.033 -10.429 -2.262 1.00 17.07 ... (8 Replies)
Discussion started by: doom4
8 Replies
LEARN ABOUT DEBIAN
qssign
QSSIGN(1) qssign man page QSSIGN(1)
NAME
qssign - Utility to sign and verify the integrity of log data.
SYNOPSIS
qssign -s|S <secret> [-e] [-v]
DESCRIPTION
qssign is a log data integrity check tool. It reads log data from stdin (pipe) and writes the signed data to stdout.
OPTIONS
-s <secret>
Passphrase used to calculate signature.
-S <program>
Specifies a program which writes the passphrase to stdout.
-e Writes end marker when stopping data signing.
-v Verification mode checking the integrity of signed data.
EXAMPLE
Sign:
TransferLog "|./bin/qssign -s password -e |./bin/qsrotate -o /var/log/apache/access_log"
Verify:
cat access_log | qssign -s password -v
SEE ALSO
qsexec(1), qsfilter2(1), qsgeo(1), qsgrep(1), qslog(1), qslogger(1), qspng(1), qsrotate(1), qstail(1)
AUTHOR
Pascal Buchbinder, http://opensource.adnovum.ch/mod_qos/
mod_qos utilities 10.8 June 2012 QSSIGN(1)