Sponsored Content
Top Forums Shell Programming and Scripting Read file and replace a particular line if found Post 302807679 by adisky123 on Wednesday 15th of May 2013 06:51:16 AM
Old 05-15-2013
Sorry I miss that.
Suppose my file contain data is as follow
Code:
Hello I am great
My best website is Unix.com
Hello my name is adisky
Code tag button

and my search pattern will be the one of the line from file only
Code:
Code tag button

and if the pattern found it should replace with
Code:
Code tag button;Code tag button

Regards
ADI
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to replace a line below where the pattern found

Hi All, I have a file say abc.xml. In this file, I need to search for a pattern “SAP_GATEWAY_HOST”; if this pattern found and the next line also contain the pattern “nwprc03.cos” then I need to replace this pattern “nwprc03.cos” with some other pattern “nwdrc03.apjp”. $ cat abc.xml... (3 Replies)
Discussion started by: Ritesh.patni84
3 Replies

2. Shell Programming and Scripting

bash: read file line by line (lines have '\0') - not full line has read???

I am using the while-loop to read a file. The file has lines with null-terminated strings (words, actually.) What I have by that reading - just a first word up to '\0'! I need to have whole string up to 'new line' - (LF, 10#10, 16#A) What I am doing wrong? #make file 'grb' with... (6 Replies)
Discussion started by: alex_5161
6 Replies

3. Shell Programming and Scripting

Replace all found files with an empty file?

Hi all, I need to replace certain robots.txt files with an empty file. I use the following to find the files I want to empty out: find /Sites -type f -name "robots.txt" -exec grep -il "STAGE" {} \; (finds all robots.txt files which contain the string 'STAGE') Now what do I add to this... (3 Replies)
Discussion started by: Evert
3 Replies

4. UNIX for Dummies Questions & Answers

Replace line with found unknown pattern

Hi, I have a file with the following content: --------- a 3242 tc_5 gdfg4 random text a 3242 tc_6 gdfg4 random text a 3242 tc_7 gdfg4 random text a 3242 tc_4 gdfg4 --------- I want to replace the lines containing tc_? (tc_5, tc_6 etc. even with unknown numbers) with the found... (5 Replies)
Discussion started by: joas
5 Replies

5. Shell Programming and Scripting

Read file and for each line replace two variables, add strings and save output in another file

Hi All, I have a file, let's call it "info.tmp" that contains data like this .. ABC123456 PCX333445 BCD789833 I need to read "info.tmp" and for each line add strings in a way that the final output is put /logs/ua/dummy.trigger 'AAA00001.FTP.XXX.BLA03A01.xxxxxx(+1)' where XXX... (5 Replies)
Discussion started by: Andy_ARG
5 Replies

6. Programming

Perl: How to read from a file, do regular expression and then replace the found regular expression

Hi all, How am I read a file, find the match regular expression and overwrite to the same files. open DESTINATION_FILE, "<tmptravl.dat" or die "tmptravl.dat"; open NEW_DESTINATION_FILE, ">new_tmptravl.dat" or die "new_tmptravl.dat"; while (<DESTINATION_FILE>) { # print... (1 Reply)
Discussion started by: jessy83
1 Replies

7. Shell Programming and Scripting

Read line by line and replace string.

Hi, I currently have a problem that I need to read a file line by line. After I read it line by line there are some commands in which I have to change a specific string.(In my case, I have to make a script that changes all the passwords into hash value) Here is a sample input... (3 Replies)
Discussion started by: thebennnn
3 Replies

8. Shell Programming and Scripting

Replace string2 by string3 where string1 is found in line

Hello, My aim is to search string1 in all lines. When found, find and replace string2 by string3 if possible. TextFile: Here is my first line Second line with string1 & string2 Not last line but it contains string1 Expected output: Here is my first line The second line with string1 &... (6 Replies)
Discussion started by: baris35
6 Replies

9. Shell Programming and Scripting

Read each line in fileA, replace in all files with matching filename

Hello, I supposed that I asked the similar question but I could not have found it when I search on our forum. EXYU+: EXYU%3A+HRT+1 EXYU%3A+HRT+2 EXYU%3A+HRT+3 EXYU_url: #SERVICE 1:0:1:0:0:0:0:0:0:0:http%3A//xxxx%3Ayyyy@mmmm%3A55555/stream/channelname/YYYY?profile=htsp7777.ts #SERVICE... (2 Replies)
Discussion started by: baris35
2 Replies

10. UNIX for Beginners Questions & Answers

Replace string2 by string3 where string1 is found in line

I found this in the forum that searches a file for string1, substitute all occurrences of string2 with string3. (Title: Replace string2 by string3 where string1 is found in line) >> sed -i '/string1/s/string2/string3/g' TextFile How will I perform the same sed command and only substitute... (3 Replies)
Discussion started by: apalex
3 Replies
ALGOTUTOR(1)						User Contributed Perl Documentation					      ALGOTUTOR(1)

NAME
algotutor - an interactive program for observing the intermediate steps of algorithms. SYNOPSIS
algotutor [OPTION] ... DATA ... DESCRIPTION
algotutor is an interactive program for observing the intermediate steps of algorithms. The target audience is computer science students and/or anyone who studies algorithms and/or data structures. One can create data files in plain text format (actually perl anonymous hashes, but one need not care) and let algotutor runs through some predefined algorithm. Then one can step backward and forward through the execution sequence of the algorithm at different levels of details. It requires perl-Tk. DATA is the input data. For the dynamic programming algorithms such as lcs and matc, please see the respective entries in the following list; for other algorithms, it is the file name containing the actual input data. OPTIONS
-a ALGO Runs the algorithm ALGO. Currently ALGO can be one of: bst operations on binary search trees rbt operations on red-black trees (remove() is not implemented yet) heap operations on heaps -- the remove operation on a heap always removes the top element regardless of the argument sbs stack-based search on graphs, a variant of depth first search bfs breadth first search on graphs prim Prim's minimal spanning tree on graphs dijk Dijkstra's single-source shortest path on graphs flwa Floyd-Warshall's all-pair shortest path on graphs (very, very slow) dom 2-dimensional point domination graham Graham's scan for convex hull lcs longest common subsequence -- it requires two strings as the command line arguments. For example, "algotutor -a lcs AGCTATACGATGACT GTCAGTATAGTCATATG" matc optimal matrix chain multiplication -- it requires an alternating sequence of integers and matrix names as the command line arguments. For example, "algotutor -a matc 32 A 35 B 24 C 30 D 36 E 25 F 40 G 34 H 35" means finding the optimal multiplication sequence of the chain of matrices: A of size 32 by 35, B of size 35 by 24, ... H of size 34 by 35. -s VERTEX Use VERTEX as the starting vertex (for sbs, bfs, prim, and dijk) -i STEP Display step STEP as the initial image. -d FILENAME Dump the picture into FILENAME as a ps file and exit immediately without going into interactive mode. LICENSE
This code is distributed under the GNU General Public License AUTHOR
Chao-Kuei Hung ckhung AT ofset DOT org SEE ALSO
Please see /usr/share/doc/algotutor/doc/ for examples and the full set of documentations. perl v5.10.1 2010-07-05 ALGOTUTOR(1)
All times are GMT -4. The time now is 02:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy