Sponsored Content
Top Forums UNIX for Dummies Questions & Answers how to replace a text of line with a comment line Post 302317462 by Franklin52 on Tuesday 19th of May 2009 03:59:35 AM
Old 05-19-2009
Another command to substitute the line:

Code:
sed 's/\(.\)\(.*\)/\1#\2/' file

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to add a comment line in a text file

Hi I need to add a comment line at the begining of a text file. The scenario is given below. 1. The number of servers that needs to be updated is around 80 2. The location of the text file in all the servers are the same including the file name. 3. The comment has to be added at the very... (2 Replies)
Discussion started by: orakhan
2 Replies

2. UNIX for Dummies Questions & Answers

how to replace one line in text with several lines

Hi, I need to replace a specific line in a text (eg the line contains the word MYSERVER) with a number of lines (let's say 4) in which the word MYSERVER will be replaced with server1 in the first line server2 in the second line server3 in the 3rd line server4 in the 4th line The original... (1 Reply)
Discussion started by: FunnyCats
1 Replies

3. UNIX for Dummies Questions & Answers

how to use vi to replace specific line of text only

hi all, i am new bee to Unix. i know how to replace text for range of lines in vi for e.g. replace | with |||| for line 4 through 7 using vi : 4,7s/|/||||/g but i have to replace | with |||| only for line no 4, 7 and 10 using vi only!!! your help will be appreciated! thanks,... (4 Replies)
Discussion started by: pranav.pandya
4 Replies

4. UNIX for Dummies Questions & Answers

how to replace this text with comment

test compare shown] Replace this text with #test compare shown] (1 Reply)
Discussion started by: manoj.b
1 Replies

5. Solaris

Line too long error Replace string with new line line character

I get a file which has all its content in a single row. The file contains xml data containing 3000 records, but all in a single row, making it difficult for Unix to Process the file. I decided to insert a new line character at all occurrences of a particular string in this file (say replacing... (4 Replies)
Discussion started by: ducati
4 Replies

6. Shell Programming and Scripting

comment a line of the patterns is a the beginning of the line

I need to comment the lines starting with pattern "exclude" or "exclude=". If the work exclude comes at any other part, ignore it. Also, ignore, excludes, excluded etc. Ie only comment the line starting with exclude. File contents. exclude exclude= hi I am excluded excludes excludes= ... (9 Replies)
Discussion started by: anil510
9 Replies

7. Shell Programming and Scripting

sed command to replace a line at a specific line number with some other line

my requirement is, consider a file output 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 ... (3 Replies)
Discussion started by: vivek d r
3 Replies

8. Shell Programming and Scripting

Search text and replace line next to it

I have a file which requires modification via a shell script. Need to do the following: 0. take input from user for new text. 1. search for a keyword in the file. 2. replace the line next to this to this keyword with user supplied input. for e.g., my file has the following text: (some... (7 Replies)
Discussion started by: chingupt
7 Replies

9. Shell Programming and Scripting

How to find text and replace next line.?

Have multiple files with the same format and certain text is the same. Have specific text to search for and then need to replace the next line. Can search on the text DEVICE and multiple lines will be found. The line after each DEVICE line has {. Want to replace the line { with {-someadditiontext.... (2 Replies)
Discussion started by: bigdaddywags
2 Replies

10. Shell Programming and Scripting

Script using awk to find and replace a line, how to ignore comment lines

Hello, I have some code that works more or less. This is called by a make file to adjust some hard-coded definitions in the src code. The script generated some values by looking at some of the src files and then writes those values to specific locations in other files. The awk code is used to... (3 Replies)
Discussion started by: LMHmedchem
3 Replies
TAP::Parser::Result::Test(3)				User Contributed Perl Documentation			      TAP::Parser::Result::Test(3)

NAME
TAP::Parser::Result::Test - Test result token. VERSION
Version 3.28 DESCRIPTION
This is a subclass of TAP::Parser::Result. A token of this class will be returned if a test line is encountered. 1..1 ok 1 - woo hooo! OVERRIDDEN METHODS
This class is the workhorse of the TAP::Parser system. Most TAP lines will be test lines and if "$result->is_test", then you have a bunch of methods at your disposal. Instance Methods "ok" my $ok = $result->ok; Returns the literal text of the "ok" or "not ok" status. "number" my $test_number = $result->number; Returns the number of the test, even if the original TAP output did not supply that number. "description" my $description = $result->description; Returns the description of the test, if any. This is the portion after the test number but before the directive. "directive" my $directive = $result->directive; Returns either "TODO" or "SKIP" if either directive was present for a test line. "explanation" my $explanation = $result->explanation; If a test had either a "TODO" or "SKIP" directive, this method will return the accompanying explanation, if present. not ok 17 - 'Pigs can fly' # TODO not enough acid For the above line, the explanation is not enough acid. "is_ok" if ( $result->is_ok ) { ... } Returns a boolean value indicating whether or not the test passed. Remember that for TODO tests, the test always passes. If the test is unplanned, this method will always return false. See "is_unplanned". "is_actual_ok" if ( $result->is_actual_ok ) { ... } Returns a boolean value indicating whether or not the test passed, regardless of its TODO status. "actual_passed" Deprecated. Please use "is_actual_ok" instead. "todo_passed" if ( $test->todo_passed ) { # test unexpectedly succeeded } If this is a TODO test and an 'ok' line, this method returns true. Otherwise, it will always return false (regardless of passing status on non-todo tests). This is used to track which tests unexpectedly succeeded. "todo_failed" # deprecated in favor of 'todo_passed'. This method was horribly misnamed. This was a badly misnamed method. It indicates which TODO tests unexpectedly succeeded. Will now issue a warning and call "todo_passed". "has_skip" if ( $result->has_skip ) { ... } Returns a boolean value indicating whether or not this test has a SKIP directive. "has_todo" if ( $result->has_todo ) { ... } Returns a boolean value indicating whether or not this test has a TODO directive. "as_string" print $result->as_string; This method prints the test as a string. It will probably be similar, but not necessarily identical, to the original test line. Directives are capitalized, some whitespace may be trimmed and a test number will be added if it was not present in the original line. If you need the original text of the test line, use the "raw" method. "is_unplanned" if ( $test->is_unplanned ) { ... } $test->is_unplanned(1); If a test number is greater than the number of planned tests, this method will return true. Unplanned tests will always return false for "is_ok", regardless of whether or not the test "has_todo". Note that if tests have a trailing plan, it is not possible to set this property for unplanned tests as we do not know it's unplanned until the plan is reached: print <<'END'; ok 1 ok 2 1..1 END perl v5.16.3 2013-05-02 TAP::Parser::Result::Test(3)
All times are GMT -4. The time now is 11:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy