Sponsored Content
Top Forums Shell Programming and Scripting sed command to replace a line at a specific line number with some other line Post 302797741 by vivek d r on Tuesday 23rd of April 2013 06:07:02 AM
Old 04-23-2013
sed command to replace a line at a specific line number with some other line

my requirement is,

consider a file output

Code:
cat output
 
blah sdjfhjkd jsdfhjksdh
sdfs 23423 sdfsdf sdf"sdfsdf"sdfsdf"""""dsf
 hellow there 
this doesnt look good
et cetc etc
etcetera


i want to replace a line of line number 4 ("this doesnt look good") with some other line


say echo "me there $chco" (with the echo command)

the below is not doing the job... i dont watnt to replace a string. All i need is it should delete line 4 and replace my whole sentence in that line

Code:
 
 sed -i '4 s|*|echo \"me there \$ech\" |'  output

PS: i dont want to perform any file redirection either
any help is appreciated thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Adding a columnfrom a specifit line number to a specific line number

Hi, I have a huge file & I want to add a specific text in column. But I want to add this text from a specific line number to a specific line number & another text in to another range of line numbers. To be more specific: lets say my file has 1000 lines & 4 Columns. I want to add text "Hello"... (2 Replies)
Discussion started by: Ezy
2 Replies

2. Shell Programming and Scripting

using sed to replace a specific string on a specific line number using variables

using sed to replace a specific string on a specific line number using variables this is where i am at grep -v WARNING output | grep -v spawn | grep -v Passphrase | grep -v Authentication | grep -v '/sbin/tfadmin netguard -C'| grep -v 'NETWORK>' >> output.clean grep -n Destination... (2 Replies)
Discussion started by: todd.cutting
2 Replies

3. Shell Programming and Scripting

How would i delete a line at specific line number

Hi guys , I m writing a script to delete a line at particular location. But i m unable to use variable for specifying line number. for example. sed -n '7!p' filename works fine and deletes 7th line from my file but sed -n '$variable!p' filename gives following error. sed: -e... (12 Replies)
Discussion started by: pinga123
12 Replies

4. Shell Programming and Scripting

sed script - print the line number along with the line

Hi, I want to print the line number with the pattern of the line on a same line using multi-patterns in sed. But i don't know how to do it. For example, I have a file abc def ghi I want to print 1 abc 2 def 3 ghi I know how to write it one line code, but i don't know how to put... (11 Replies)
Discussion started by: ntpntp
11 Replies

5. Shell Programming and Scripting

Replace specific field on specific line sed or awk

I'm trying to update a text file via sed/awk, after a lot of searching I still can't find a code snippet that I can get to work. Brief overview: I have user input a line to a variable, I then find a specific value in this line 10th field in this case. After asking for new input and doing some... (14 Replies)
Discussion started by: crownedzero
14 Replies

6. Shell Programming and Scripting

I need to know how to replace a line after a pattern match with an empty line using SED

Hi How Are you? I am doing fine! I need to go now? I will see you tomorrow! Basically I need to replace the entire line containing "doing" with a blank line: I need to the following output: Hi How Are you? I need to go now? I will see you tomorrow! Thanks in advance.... (1 Reply)
Discussion started by: sags007_99
1 Replies

7. Shell Programming and Scripting

sed to replace specific positions on line with file contents

Hi, I am trying to use an awk command to replace specific character positions on a line beginning with 80 with contents of another file. The line beginning with 80 in file1 is as follows: I want to replace the 000000000178800 (positions 34 - 49) on this file with the contents of... (2 Replies)
Discussion started by: nwalsh88
2 Replies

8. Shell Programming and Scripting

Multiple line search, replace second line, using awk or sed

All, I appreciate any help you can offer here as this is well beyond my grasp of awk/sed... I have an input file similar to: &LOG &LOG Part: "@DB/TC10000021855/--F" &LOG &LOG &LOG Part: "@DB/TC10000021852/--F" &LOG Cloning_Action: RETAIN &LOG Part: "@DB/TCCP000010713/--A" &LOG &LOG... (5 Replies)
Discussion started by: KarmaPoliceT2
5 Replies

9. Shell Programming and Scripting

sed command to replace a line in a file using line number from the output of a pipe.

Sed command to replace a line in a file using line number from the output of a pipe. Is it possible to replace a whole line piped from someother command into a file at paritcular line... here is some basic execution flow.. the line number is 412 lineNo=412 Now i have a line... (1 Reply)
Discussion started by: vivek d r
1 Replies

10. Shell Programming and Scripting

Replace values in script reading line by line using sed

Hi all, Let's say I have a script calling for the two variables PA_VALUE and PB_VALUE. for pa in PA_VALUE blah blah do for pb in PB_VALUE blah blah do I have a text file with two columns of values for PA and PB. 14.5 16.7 7.8 9.5 5.6 3.6 etc etc I would like to read this... (7 Replies)
Discussion started by: crimsonengineer
7 Replies
GST-CONVERT(1)							   User Commands						    GST-CONVERT(1)

NAME
gst-convert - Smalltalk syntax converter and beautifier DESCRIPTION
Usage: gst-convert [OPTION]... [INFILE [OUTFILE]] gst-convert [OPTION]... -o|--output OUTFILE INFILES OPTIONS
-q, --quiet don't show any message -v, --verbose print extra information while processing -f, --format=FORMAT convert from given input format (supported formats are gst, gst2, sif, squeak) -F, --output-format=FORMAT convert to given output format (supported formats are gst, gst2, squeak) -C, --class=REGEX convert only classes matching REGEX -C, --class=+REGEX in addition, convert classes matching REGEX -C, --class=-REGEX do not convert classes matching REGEX -c, --category=REGEX convert only classes whose category matches REGEX -c, --category=+REGEX in addition, convert those whose category matches REGEX -c, --category=-REGEX do not convert classes whose category matches REGEX -r, --rule='CODE->REPL' look for CODE and replace it with REPL -o, --output OUTFILE concatenate multiple input files into a single converted output file --help display this message and exit --version print version information and exit SEE ALSO
The full documentation for gst-convert is maintained as a Texinfo manual. If the info and gst-convert programs are properly installed at your site, the command info gst should give you access to the complete manual. gst-convert version 3.2.4 December 2011 GST-CONVERT(1)
All times are GMT -4. The time now is 03:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy