Sponsored Content
Top Forums Shell Programming and Scripting How to search and replace text in same file Post 302189138 by Vrgurav on Friday 25th of April 2008 05:02:19 AM
Old 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

automating file search and replace text

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

search and replace a specific text in text file?

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

how can search a String in one text file and replace the whole line in another file

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

search and replace a text in a file

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

text file search and replace with awk

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

Search replace strings between single quotes in a text file

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

Search and replace in text file

Hi, I have gigabytes of text files that I need to search for "&" and replace with "&amp". 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

gawk script to search and replace text in a flat file

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

Search and replace from file in awk using a 16 bit text file

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

Search field in text file and replace value

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
WNDB(5WN)						      WordNettm File Formats							 WNDB(5WN)

NAME
index.noun, data.noun, index.verb, data.verb, index.adj, data.adj, index.adv, data.adv - WordNet database files noun.exc, verb.exc. adj.exc adv.exc - morphology exception lists sentidx.vrb, sents.vrb - files used by search code to display sentences illustrating the use of some specific verbs DESCRIPTION
For each syntactic category, two files are needed to represent the contents of the WordNet database - index.pos and data.pos, where pos is noun, verb, adj and adv. The other auxiliary files are used by the WordNet library's searching functions and are needed to run the various WordNet browsers. Each index file is an alphabetized list of all the words found in WordNet in the corresponding part of speech. On each line, following the word, is a list of byte offsets (synset_offsets) in the corresponding data file, one for each synset containing the word. Words in the index file are in lower case only, regardless of how they were entered in the lexicographer files. This folds various orthographic repre- sentations of the word into one line enabling database searches to be case insensitive. See wninput(5WN) for a detailed description of the lexicographer files A data file for a syntactic category contains information corresponding to the synsets that were specified in the lexicographer files, with relational pointers resolved to synset_offsets. Each line corresponds to a synset. Pointers are followed and hierarchies traversed by moving from one synset to another via the synset_offsets. The exception list files, pos.exc, are used to help the morphological processor find base forms from irregular inflections. The files sentidx.vrb and sents.vrb contain sentences illustrating the use of specific senses of some verbs. These files are used by the searching software in response to a request for verb sentence frames. Generic sentence frames are displayed when an illustrative sentence is not present. The various database files are in ASCII formats that are easily read by both humans and machines. All fields, unless otherwise noted, are separated by one space character, and all lines are terminated by a newline character. Fields enclosed in italicized square brackets may not be present. See wngloss(7WN) for a glossary of WordNet terminology and a discussion of the database's content and logical organization. Index File Format Each index file begins with several lines containing a copyright notice, version number and license agreement. These lines all begin with two spaces and the line number so they do not interfere with the binary search algorithm that is used to look up entries in the index files. All other lines are in the following format. In the field descriptions, number always refers to a decimal integer unless otherwise defined. lemma pos synset_cnt p_cnt [ptr_symbol...] sense_cnt tagsense_cnt synset_offset [synset_offset...] lemma lower case ASCII text of word or collocation. Collocations are formed by joining individual words with an underscore (_) character. pos Syntactic category: n for noun files, v for verb files, a for adjective files, r for adverb files. All remaining fields are with respect to senses of lemma in pos. synset_cnt Number of synsets that lemma is in. This is the number of senses of the word in WordNet. See Sense Numbers below for a dis- cussion of how sense numbers are assigned and the order of synset_offsets in the index files. p_cnt Number of different pointers that lemma has in all synsets containing it. ptr_symbol A space separated list of p_cnt different types of pointers that lemma has in all synsets containing it. See wninput(5WN) for a list of pointer_symbols. If all senses of lemma have no pointers, this field is omitted and p_cnt is 0. sense_cnt Same as sense_cnt above. This is redundant, but the field was preserved for compatibility reasons. tagsense_cnt Number of senses of lemma that are ranked according to their frequency of occurrence in semantic concordance texts. synset_offset Byte offset in data.pos file of a synset containing lemma. Each synset_offset in the list corresponds to a different sense of lemma in WordNet. synset_offset is an 8 digit, zero-filled decimal integer that can be used with fseek(3) to read a synset from the data file. When passed to read_synset(3WN) along with the syntactic category, a data structure containing the parsed synset is returned. Data File Format Each data file begins with several lines containing a copyright notice, version number and license agreement. These lines all begin with two spaces and the line number. All other lines are in the following format. Integer fields are of fixed length, and are zero-filled. synset_offset lex_filenum ss_type w_cnt word lex_id [word lex_id...] p_cnt [ptr...] [frames...] | gloss synset_offset Current byte offset in the file represented as an 8 digit decimal integer. lex_filenum Two digit decimal integer corresponding to the lexicographer file name containing the synset. See lexnames(5WN) for the list of filenames and their corresponding numbers. ss_type One character code indicating the synset type: n NOUN v VERB a ADJECTIVE s ADJECTIVE SATELLITE r ADVERB w_cnt Two digit hexadecimal integer indicating the number of words in the synset. word ASCII form of a word as entered in the synset by the lexicographer, with spaces replaced by underscore characters (_). The text of the word is case sensitive, in contrast to its form in the corresponding index.pos file, that contains only lower- case forms. In data.adj, a word is followed by a syntactic marker if one was specified in the lexicographer file. A syn- tactic marker is appended, in parentheses, onto word without any intervening spaces. See wninput(5WN) for a list of the syntactic markers for adjectives. lex_id One digit hexadecimal integer that, when appended onto lemma, uniquely identifies a sense within a lexicographer file. lex_id numbers usually start with 0, and are incremented as additional senses of the word are added to the same file, although there is no requirement that the numbers be consecutive or begin with 0. Note that a value of 0 is the default, and therefore is not present in lexicographer files. p_cnt Three digit decimal integer indicating the number of pointers from this synset to other synsets. If p_cnt is 000 the synset has no pointers. ptr A pointer from this synset to another. ptr is of the form: pointer_symbol synset_offset pos source/target where synset_offset is the byte offset of the target synset in the data file corresponding to pos. The source/target field distinguishes lexical and semantic pointers. It is a four byte field, containing two two-digit hexadecimal integers. The first two digits indicates the word number in the current (source) synset, the last two digits indicate the word number in the target synset. A value of 0000 means that pointer_symbol represents a semantic relation between the current (source) synset and the target synset indicated by synset_offset. A lexical relation between two words in different synsets is represented by non-zero values in the source and target word numbers. The first and last two bytes of this field indicate the word numbers in the source and target synsets, respec- tively, between which the relation holds. Word numbers are assigned to the word fields in a synset, from left to right, beginning with 1. See wninput(5WN) for a list of pointer_symbols, and semantic and lexical pointer classifications. frames In data.verb only, a list of numbers corresponding to the generic verb sentence frames for words in the synset. frames is of the form: f_cnt + f_num w_num [ + f_num w_num...] where f_cnt a two digit decimal integer indicating the number of generic frames listed, f_num is a two digit decimal integer frame number, and w_num is a two digit hexadecimal integer indicating the word in the synset that the frame applies to. As with pointers, if this number is 00, f_num applies to all words in the synset. If non-zero, it is applicable only to the word indicated. Word numbers are assigned as described for pointers. Each f_num w_num pair is preceded by a +. See wnin- put(5WN) for the text of the generic sentence frames. gloss Each synset contains a gloss. A gloss is represented as a vertical bar (|), followed by a text string that continues until the end of the line. The gloss may contain a definition, one or more example sentences, or both. Sense Numbers Senses in WordNet are generally ordered from most to least frequently used, with the most common sense numbered 1. Frequency of use is determined by the number of times a sense is tagged in the various semantic concordance texts. Senses that are not semantically tagged follow the ordered senses. The tagsense_cnt field for each entry in the index.pos files indicates how many of the senses in the list have been tagged. The cntlist(5WN) file provided with the database lists the number of times each sense is tagged in the semantic concordances. The data from cntlist is used by grind(1WN) to order the senses of each word. When the index.pos files are generated, the synset_offsets are output in sense number order, with sense 1 first in the list. Senses with the same number of semantic tags are assigned unique but consecutive sense numbers. The WordNet OVERVIEW search displays all senses of the specified word, in all syntactic categories, and indicates which of the senses are represented in the semantically tagged texts. Exception List File Format Exception lists are alphabetized lists of inflected forms of words and their base forms. The first field of each line is an inflected form, followed by a space separated list of one or more base forms of the word. There is one exception list file for each syntactic cate- gory. Note that the noun and verb exception lists were automatically generated from a machine-readable dictionary, and contain many words that are not in WordNet. Also, for many of the inflected forms, base forms could be easily derived using the standard rules of detachment pro- grammed into Morphy (See morph(7WN)). These anomalies are allowed to remain in the exception list files, as they do no harm. Verb Example Sentences For some verb senses, example sentences illustrating the use of the verb sense can be displayed. Each line of the file sentidx.vrb con- tains a sense_key followed by a space and a comma separated list of example sentence template numbers, in decimal. The file sents.vrb lists all of the example sentence templates. Each line begins with the template number followed by a space. The rest of the line is the text of a template example sentence, with %s used as a placeholder in the text for the verb. Both files are sorted alphabetically so that the sense_key and template sentence number can be used as indices, via binsrch(3WN), into the appropriate file. When a request for FRAMES is made, the WordNet search code looks for the sense in sentidx.vrb. If found, the sentence template(s) listed is retrieved from sents.vrb, and the %s is replaced with the verb. If the sense is not found, the applicable generic sentence frame(s) listed in frames is displayed. NOTES
Information in the data.pos and index.pos files represents all of the word senses and synsets in the WordNet database. The word, lex_id, and lex_filenum fields together uniquely identify each word sense in WordNet. These can be encoded in a sense_key as described in sen- seidx(5WN). Each synset in the database can be uniquely identified by combining the synset_offset for the synset with a code for the syn- tactic category (since it is possible for synsets in different data.pos files to have the same synset_offset). The WordNet system provide both command line and window-based browser interfaces to the database. Both interfaces utilize a common library of search and morphology code. The source code for the library and interfaces is included in the WordNet package. See wnintro(3WN) for an overview of the WordNet source code. ENVIRONMENT VARIABLES (UNIX) WNHOME Base directory for WordNet. Default is /usr/local/WordNet-3.0. WNSEARCHDIR Directory in which the WordNet database has been installed. Default is WNHOME/dict. REGISTRY (WINDOWS) HKEY_LOCAL_MACHINESOFTWAREWordNet3.0WNHome Base directory for WordNet. Default is C:Program FilesWordNet3.0. FILES
index.pos database index files data.pos database data files *.vrb files of sentences illustrating the use of verbs pos.exc morphology exception lists SEE ALSO
grind(1WN), wn(1WN), wnb(1WN), wnintro(3WN), binsrch(3WN), wnintro(5WN), cntlist(5WN), lexnames(5WN), senseidx(5WN), wninput(5WN), mor- phy(7WN), wngloss(7WN), wngroups(7WN), wnstats(7WN). WordNet 3.0 Dec 2006 WNDB(5WN)
All times are GMT -4. The time now is 08:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy