Sponsored Content
Full Discussion: Replace text in a file
Top Forums Shell Programming and Scripting Replace text in a file Post 302970833 by rdrtx1 on Tuesday 12th of April 2016 09:48:27 AM
Old 04-12-2016
Is $filename name /tmp/odbc.ini.2014_old or /tmp/odbc.ini_old?

The code shown above will remove the line matching the string. For replacing string try updating to:
Code:
#!/usr/bin/perl

use strict;
use warnings;

my $filename = '/tmp/odbc.ini.2014_old';
my $find=' sql7.0.1 ';
my $replace = ' sqls715 ';

{
   local @ARGV =($filename);
   local $^I ='.bac';
   while (<>) {
      if (s/$find/$replace/ig) {
         print;
      } else {
         print;
      }
   }
}
print "Finished\n";

(after the $filename is verified)
This User Gave Thanks to rdrtx1 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace text in input file

I wish to replace values of specific parameters in an input file for batch runs of a java code. It's essentially a nested for-loop sorta like this: valuearray1 contains values for param1 valuearray2 contains values for param2 for (all values in valuearray1) go into specific position in... (2 Replies)
Discussion started by: daphantomica
2 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

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

5. Shell Programming and Scripting

How to replace 0a with 0d0a in the text file?

Hello, I must replace all occurences of 0a character in a text file with 2 characters 0d0a. I've tried sed, but it cannot insert control characters ie. \n \r - it simply writes \n \r into output file. What is the good solution for my problem? I use ksh and AIX 5.3 operating system. Tia Yac (8 Replies)
Discussion started by: Yac
8 Replies

6. Shell Programming and Scripting

Replace char on text file

Hi , I have problem on replace char on text file #!/bin/bash echo "Enter Third value : " read a sed '2 s/192.160.1.1/cut -d"." -f3/$a/g' tcpip.txt > a.txt I want replace line 2 on tcpip.txt with value a that I input but it's not run Please help me (2 Replies)
Discussion started by: phillipss
2 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. 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

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

10. 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
PLTEXT(3plplot) 						    PLplot API							   PLTEXT(3plplot)

NAME
pltext - Switch to text screen SYNOPSIS
pltext() DESCRIPTION
Sets an interactive device to text mode, used in conjunction with plgra(3plplot) to allow graphics and text to be interspersed. On a device which supports separate text and graphics windows, this command causes control to be switched to the text window. This can be use- ful for printing diagnostic messages or getting user input, which would otherwise interfere with the plots. The program must switch back to the graphics window before issuing plot commands, as the text (or console) device will probably become quite confused otherwise. If already in text mode, this command is ignored. It is also ignored on devices which only support a single window or use a different method for shifting focus (see also plgra(3plplot)). Redacted form: pltext() This function is used in example 1. AUTHORS
Geoffrey Furnish and Maurice LeBrun wrote and maintain PLplot. This man page was automatically generated from the DocBook source of the PLplot documentation, maintained by Alan W. Irwin and Rafael Laboissiere. SEE ALSO
PLplot documentation at http://plplot.sourceforge.net/resources. August, 2012 PLTEXT(3plplot)
All times are GMT -4. The time now is 06:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy