Sponsored Content
Top Forums Shell Programming and Scripting Replacing a line in a file - HELP!!! Post 302202463 by jaduks on Wednesday 4th of June 2008 11:55:00 PM
Old 06-05-2008
See this:

Code:
$ cat ea.txt
root 1933 1923 localhost calm 32rhewr

$ A=root

$ B=ROOT

$ sed 's/$A/$B/g' ea.txt
root 1933 1923 localhost calm 32rhewr

**No change above

So use double quotes instead of single quote: 

$ sed "s/$A/$B/g" ea.txt
ROOT 1933 1923 localhost calm 32rhewr

So 

LINECHANGE=`sed s/$OLDLINE/$NEWLINE/ $filename`

should be something like this:

LINECHANGE=`sed "s/$OLDLINE/$NEWLINE/" $filename`

//Jadu
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

replacing first line or lines in a file

hey guys, how do i replace only a line within a file without messing up the rest of the contents of the file? see, if possible can you guys give me a straight forward way to do this. i dont want a complex command. what i mean is i know i can accomplish this by using sed, well, i think i can,... (3 Replies)
Discussion started by: Terrible
3 Replies

2. Shell Programming and Scripting

Replacing characters in file with line break

Hi, Apologies if this has been asked before, but I searched and was not able to find an answer. It's probably a simple question to answer for those of you with some experience, though... I have a relatively long string where tokens are separated by the colon (':') character. Let's say the... (10 Replies)
Discussion started by: johnemb
10 Replies

3. Shell Programming and Scripting

replacing a line of unknown charecters in a file

Hi All I have a requirement where using a script I grep a file for string (KSG/Password in below ) , get the next line which is the password and I need replace the whole line of unknown special charecters (encrypted password) with another line as given below . As in below i need to get... (12 Replies)
Discussion started by: malavm
12 Replies

4. Shell Programming and Scripting

Replacing the last character for each line in a file

Hello, I have a csv file and will like to replace the last character of each line in the file with Z (20 Replies)
Discussion started by: 123script
20 Replies

5. Shell Programming and Scripting

Replacing space with T only in the 1st line of the file

Hi Masters , I have a file whose header is like HDRCZECM8CZCM000000881 SVR00120100401160828+020020100401160828+0200CZK There is a space between 1 and S ,my req is to chng the space to T I tried echo `head -1 CDCZECM8CZCM000000881` | sed 's/ /T/' it works ,but how can I modify in... (5 Replies)
Discussion started by: Pratik4891
5 Replies

6. UNIX for Dummies Questions & Answers

Replacing first line of file by >filename

Hi All, I have a set of files named S5_SK1.chr01 S5_SK1.chr02 S5_SK1.chr03 ..... and the first line of these files is >SK1.chr01 >SK1.chr02 >SK1.chr03 ..... Can anyone suggest how I can change the first line of all these files with the filename itself? So my expected output for the first lines of... (14 Replies)
Discussion started by: pawannoel
14 Replies

7. Shell Programming and Scripting

Replacing line 'i' of file1 with line 'j' of file 2

Hi All, As mentioned in the title I have two text files and I would like to replace line number 5 of file #1 with line number 4 of file #2 e.g. file 1 wqwert 4.4464002 3 319 286 369 46.320002 56.150002 45.100002 1 1 1 0.723 (12 Replies)
Discussion started by: f_o_555
12 Replies

8. Shell Programming and Scripting

Replacing a line in a file using sed

I have a file which has a list in it pop triangle people slow fast What I want to do is search this list and replace people with humans do the list looks like this: pop triangle human slow fast I think i use something like this.... if cat /list.txt | grep -q 'people' ; then (9 Replies)
Discussion started by: digitalviking
9 Replies

9. Shell Programming and Scripting

Replacing a line in a file

Hi all, I need to replace a line export TZ=xxxxxxxx with the line export TZ=$1 Now, "xxxxxxxx" in the above line is some unknown string and $1 is a parameter. I want the content of $1 to be replaced with "xxxxxxxx". Kindly help me how to do this in the shell scripting. (5 Replies)
Discussion started by: ddeeps2610
5 Replies

10. Shell Programming and Scripting

Replacing last line with awk and change the file name

Hi Guys, I am having a set of date format files files where I am performing the below set of operations in the files . I Need to replace the last line value with specific date which is a pipe delimited file. for egf1_20140101.txt aa|aus|20140101|yy bb|nz|20140101|yy . .... (19 Replies)
Discussion started by: rohit_shinez
19 Replies
ROOT(1) 						      General Commands Manual							   ROOT(1)

NAME
root - Interpretor of C++ for the ROOT framework SYNOPSIS
root [options] files ... DESCRIPTION
ROOTs Object-Oriented Technologies. root is a interactive interpretor of C++ code. It uses the ROOT framework. For more information on ROOT, please refer to http://root.cern.ch. An extensive Users Guide is available from that site. OPTIONS
-? Show summary of options. -b Run in batch mode without graphics -n Do not execute logon and logoff macros as specified in .rootrc -q Exit after processing command line macro files -l Do not show splash screen SEE ALSO
rootcint(1), cint(1), root-config(1), rootd(1), h2root(1), g2root(1) For extensive documentation on the ROOT system, see http://root.cern.ch <http://root.cern.ch> A Users Guide is available online. <http://root.cern.ch/root/UsersGuide.html> The classes of ROOT are all documented by the automatic documentation system, and is available online. <http://root.cern.ch/root/html/ClassIndex.html> FILES
<etcdir>/system.rootrc System-wide configuration file. <etcdir> either ROOTSYS, or something like /etc/root <libdir>/* ROOT C++ class libraries. <libdir> is either ROOTSYS/lib or something like /usr/lib/root. <incdir>/* The header files for the ROOT C++ class libraries. <incdir> is either ROOTSYS/include or something like /usr/include/root. ~/.rootrc, ./.rootrc User configuration file ORIGINAL AUTHORS
The ROOT team (see web page above): Rene Brun and Fons Rademakers COPYRIGHT
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as pub- lished by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foun- dation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA AUTHOR
This manual page was written by Christian Holm Christensen <cholm@nbi.dk>, for the Debian GNU/Linux system (but may be used by others). ROOT
Version 3 ROOT(1)
All times are GMT -4. The time now is 10:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy