Sponsored Content
Top Forums Shell Programming and Scripting script - replace text in file Post 94431 by frustrated1 on Saturday 31st of December 2005 06:54:56 AM
Old 12-31-2005
ok - not quite what I am after



This is the result I get with your command based on the file I created test1
sed -e 's_^\(0232 \)red\( testing4\)$_\1blue\2\nInfo:Line changed_g' test1
0001 blue testing1
0002 blue testing2
0006 blue testing3
0232 blue testing4nInfo:Line changed
2143 blue testing5
3453 blue testing6

1st point - I will only know the number at the start of the line and the colour... I will not know what is contained on the rest of the line so I can use 'testing4' in my sed string

2nd point - this only returns the output to screen but the original file remains unchanged. I need to change the original file - bare in mind the original file could contain 300000 lines and I only want to change one..


Can you still help? Smilie
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. Shell Programming and Scripting

How to replace text in a file with text entered

I am trying to write a shell script that will allow the typing of a value, then using that value to replace data in a text file. I suspect I need sed. The format of the file is: Variable1:Value1 Variable2:Value2 The interaction would be something like: Shell Prompt: "Please enter the... (9 Replies)
Discussion started by: cleanden
9 Replies

4. Shell Programming and Scripting

Shell Script to replace text

I need a little help with a shell script. I want to be able to specify parameters so that the script searches multiple files (specified as parameters) and only modifies the file if it finds the string of text. For the files it doesn't find the string of text within, it should leave it alone. ... (4 Replies)
Discussion started by: joebaber
4 Replies

5. 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

6. Shell Programming and Scripting

perl script to replace the text in the original file

Hi Folks, I have an html file which contains the below line in the body tagI am trying the replace hello with Hello Giridhar programatically. <body> <P><STRONG><FONT face="comic sans ms,cursive,sans-serif"><EM>Hello</EM></FONT></STRONG></P> </body> I have written the below code to... (3 Replies)
Discussion started by: giridhar276
3 Replies

7. Shell Programming and Scripting

Replace text in column1 of a file matching columns of another file

Hi all, I have 2 files: species-names.txt Abaca-bunchy-top-virus ((((Abaca-bunchy-top-virus((Babuvirus((Unassigned((Nanoviridae((Unassigned)))) Abutilon-mosaic-virus ((((Abutilon-mosaic-virus((Begomovirus((Unassigned((Geminiviridae((Unassigned))))... (2 Replies)
Discussion started by: thienxho
2 Replies

8. Windows & DOS: Issues & Discussions

2 Questions: replace text in txt file, add text to end of txt file

so... Lets assume I have a text file. The text file contains multiple "#" symbols. I want to replace all thos "#"s with a STRING using DOS/Batch I want to add a certain TEXT to the end of each line. How can I do this WITHOUT aid of sed, grep or anything linux related ? (1 Reply)
Discussion started by: pasc
1 Replies

9. Shell Programming and Scripting

Bash script to replace text file from a lookup file

Hi. I need assistance with the replacing of text into a specific file via a bash script. My bash script, once run, currently provides a menu of computer names to choose.The script copies onto my system various files, depending what computer was selected in the menu.This is working OK. Now, I... (1 Reply)
Discussion started by: jonesn2000
1 Replies

10. Shell Programming and Scripting

Replace text in a file

I wrote a program using Perl to find and replace a text within a file. The text that needs to be replaced in the file is 'sql7.0.1' with 'sqls715'. When I execute my program I get an error message: Here is my code: #!/usr/bin/perl use strict; use warnings; my $filename =... (6 Replies)
Discussion started by: dellanicholson
6 Replies
ppmdither(1)						      General Commands Manual						      ppmdither(1)

NAME
ppmdither - ordered dither for color images SYNOPSIS
ppmdither [-dim power] [-red shades] [-green shades] [-blue shades] [ppmfile] DESCRIPTION
Reads a portable pixmap as input, and applies dithering to it to reduce the number of colors used down to the specified number of shades for each primary. The default number of shades is red=5, green=9, blue=5, for a total of 225 colors. To convert the image to a binary rgb format suitable for color printers, use -red 2 -green 2 -blue 2. OPTIONS
-dim power The size of the dithering matrix. The dithering matrix is a square whose dimension is a power of 2. power is that power of 2. The default is 4, for a 16 by 16 matrix. -red shades The number of red shades to be used, including black; minimum of 2. -green shades The number of green shades to be used, including black; minimum of 2. -blue shades The number of blue shades to be used, including black; minimum of 2. SEE ALSO
pnmdepth(1), ppmquant(1), ppm(5) AUTHOR
Copyright (C) 1991 by Christos Zoulas. 14 July 1991 ppmdither(1)
All times are GMT -4. The time now is 09:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy