Sponsored Content
Top Forums Shell Programming and Scripting find a string in a file and add some text after that file Post 302312059 by vgersh99 on Thursday 30th of April 2009 09:30:16 AM
Old 04-30-2009
ok - misread the original requirements - sorry 'bout that.

Given 'source1':
Code:
Before Head
<head>
## Text to be added
</head>

<BODY>
dskls
</BODY>

and myFile:
Code:
source1|target1|yes
source2|target2|no

.... and tasha.sh:
Code:
#!/bin/ksh

while IFS='|' read file tag yn
do
   if [ "${yn}" = 'yes' ]; then
      printf '/<head>/a\nabcd.....<%s> ...xyz\n.\nwq!\n' "${tag}"| ex - "${file}"
  fi
done < myFile

running 'tasha.sh', modifies 'source1' as:
Code:
Before Head
<head>
abcd.....<target1> ...xyz
## Text to be added
</head>

<BODY>
dskls
</BODY>

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Looking for command(s)/ script to find a text string within a file

I need to search through all files with different file suffixes in a directory structure to locate any files containing a specific string (5 Replies)
Discussion started by: wrwelden
5 Replies

2. Shell Programming and Scripting

Find string in text file

Hello! Please, help me to write such script. I have some text file with name filename.txt I must check if this file contains string "test-string-first", I must cut from this file string which follows string "keyword-string:" and till first white-space and save it to some variable. For... (3 Replies)
Discussion started by: optik77
3 Replies

3. Shell Programming and Scripting

find string(s) in text file and nearby data, export to list help

Hi, So I'm kinda new to shell scripts and the like. I've picked up quite a bit of use from browsing the forums here but ran into a new one that I can't seem to find an answer for. I'm looking to parse/find a string AND the next 15 or so charachters that follow the string within a text file... (1 Reply)
Discussion started by: kar23me
1 Replies

4. Shell Programming and Scripting

How to find repeated string in a text file

I have a text file where I need to find the string = ST*850* This string is repetaed several times in the file, so I need to know how many times it appears in the file, this is the text files: ISA*00* *00* *08*925485USNR *ZZ*IMSALADDERSP... (13 Replies)
Discussion started by: cucosss
13 Replies

5. Shell Programming and Scripting

Awk to convert a text file to CSV file with some string manipulation

Hi , I have a simple text file with contents as below: 12345678900 971,76 4234560890 22345678900 5971,72 5234560990 32345678900 71,12 6234560190 the new csv-file should be like: Column1;Column2;Column3;Column4;Column5 123456;78900;971,76;423456;0890... (9 Replies)
Discussion started by: FreddyDaKing
9 Replies

6. Shell Programming and Scripting

Search a string in a text file and add another string at the particular position of a line

I am having a text file which is having more than 200 lines. EX: 001010122 12000 BIB 12000 11200 1200003 001010122 2000 AND 12000 11200 1200003 001010122 12000 KVB 12000 11200 1200003 In the above file i want to search for string KVB and add/replace... (1 Reply)
Discussion started by: suryanarayana
1 Replies

7. Shell Programming and Scripting

Search a string in a text file and add another string at the end of line

Dear All I am having a text file which is having more than 200 lines. EX: 001010122 12000 BIB 12000 11200 1200003 001010122 2000 AND 12000 11200 1200003 001010122 12000 KVB 12000 11200 1200003 In the above file i want to search for string KVB... (5 Replies)
Discussion started by: suryanarayana
5 Replies

8. Shell Programming and Scripting

[Need help] perl script to find the occurance of string from a text file

I have two files 1. input.txt 2. keyword.txt input.txt has contents like .src_ref 0 "call.s" 24 first 0x000000 0x5a80 0x0060 BRA.l 0x60 .src_ref 0 "call.s" 30 first 0x000002 0x1bc5 RETI .src_ref 0 "call.s" 31 first 0x000003 0x6840 ... (2 Replies)
Discussion started by: acdc
2 Replies

9. Shell Programming and Scripting

Read in search strings from text file, search for string in second text file and output to CSV

Hi guys, I have a text file named file1.txt that is formatted like this: 001 , ID , 20000 002 , Name , Brandon 003 , Phone_Number , 616-234-1999 004 , SSNumber , 234-23-234 005 , Model , Toyota 007 , Engine ,V8 008 , GPS , OFF and I have file2.txt formatted like this: ... (2 Replies)
Discussion started by: An0mander
2 Replies

10. UNIX for Beginners Questions & Answers

Find and replace a string in a text file

Dear all, I want to find all the "," in my text file and then replace the commas to a tab. I found a script online but I don't know how to modify the script for my case. Any one can help? Thank you. @echo off &setlocal set "search=%1" set "replace=%2" set "textfile=Input.txt" set... (2 Replies)
Discussion started by: forevertl
2 Replies
Bio::Annotation::Target(3pm)				User Contributed Perl Documentation			      Bio::Annotation::Target(3pm)

NAME
Bio::Annotation::Target - Provides an object which represents a target (ie, a similarity hit) from one object to something in another database SYNOPSIS
$target1 = Bio::Annotation::Target->new(-target_id => 'F321966.1', -start => 1, -end => 200, -strand => 1, # or -1 ); # or $target2 = Bio::Annotation::Target->new(); $target2->target_id('Q75IM5'); $target2->start(7); # ... etc ... # Target is-a Bio::AnnotationI object, can be added to annotation # collections, e.g. the one on features or seqs $feat->annotation->add_Annotation('Target', $target2); DESCRIPTION
Provides an object which represents a target (ie, a similarity hit) from one object to something in another database without prescribing what is in the other database AUTHOR - Scott Cain Scott Cain - cain@cshl.org APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ AnnotationI implementing functions as_text Title : as_text Usage : Function: Example : Returns : Args : display_text Title : display_text Usage : my $str = $ann->display_text(); Function: returns a string. Unlike as_text(), this method returns a string formatted as would be expected for te specific implementation. One can pass a callback as an argument which allows custom text generation; the callback is passed the current instance and any text returned Example : Returns : a string Args : [optional] callback tagname Title : tagname Usage : $obj->tagname($newval) Function: Get/set the tagname for this annotation value. Setting this is optional. If set, it obviates the need to provide a tag to Bio::AnnotationCollectionI when adding this object. When obtaining an AnnotationI object from the collection, the collection will set the value to the tag under which it was stored unless the object has a tag stored already. Example : Returns : value of tagname (a scalar) Args : new value (a scalar, optional) Specific accessors for Targets target_id Usage $obj->target_id() #get existing value $obj->target_id($newval) #set new value Function Returns value of target_id (a scalar) Arguments new value of target_id (to set) perl v5.14.2 2012-03-02 Bio::Annotation::Target(3pm)
All times are GMT -4. The time now is 08:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy