Sponsored Content
Top Forums Shell Programming and Scripting search and replace, when found, delete multiple lines, add new set of lines? Post 302576103 by vgersh99 on Wednesday 23rd of November 2011 03:39:13 PM
Old 11-23-2011
Quote:
Originally Posted by DeuceLee
That is sick stuff vgersh99...unfortunately i forgot to tell you that my input.txt is a lot longer than 3 lines, say it's 6 lines, but I still don't want to overwrite the HHH.

Code:
$ cat input.txt
RRR
SSS
TTT
UUU
VVV

but I still want the "HHH". So this is more like a INSERT and not a overwrite. My bad.

Code:
$ cat testing.txt
TESTING
AAA
BBB
CCC
DDD
RRR
SSS
TTT
UUU
VVV
HHH
ENDTESTING

---------- Post updated at 04:25 PM ---------- Previous update was at 03:58 PM ----------

hey guys, actually i found a suggestion that solves one of my two problems.

Code:
Make a file, say my.sed, that contains:

s/^%%Page:.*/&\
added line 1\
added line 2\
added line 3\
added line 4/

Add more lines as needed. Then:

sed -f my.sed < infile.ps > outfile.ps

-Rouben Rostamian

I think my question is set. Thanks for looking everyone! Thanks vgersh99 for the sick one liner.
there's no limitation/hard-wiring on the number of lines to be inserted - everythig is driven by the content in your input.txt file. It should work for ANY number of lines.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Delete a block of text delimited by blank lines when pattern is found

I have a file which contains blocks of text - each block is a multi-lines text delimited by blank lines eg. <blank line> several lines of text ... pattern found on this line several more lines of text ... <blank line> How do you delete the block of text (including the blank lines) when... (17 Replies)
Discussion started by: gleu
17 Replies

2. Shell Programming and Scripting

search 2 lines and delete above line

Hi, I've been searching in this forum for the last 4 hours trying to do one thing: search 2 lines and delete the above line. So far I have not be able to find something similar in this forum, so I need help. This is what I'm trying to do. For example, I have a file called file1: file1 word1... (4 Replies)
Discussion started by: shamushamu
4 Replies

3. Shell Programming and Scripting

Multiple lines into one line when ; is found

I have sql's in a file separated by ";", need to put the sql in one single line till i find a ";" The input file is like this SELECT s.sid, s.serial#, p.spid as "OS PID", s.username, s.module, ... (6 Replies)
Discussion started by: ilugopal
6 Replies

4. Shell Programming and Scripting

Search in a set of lines using perl

Hi Experts, i am beginner in perl and need your help to find a solution.. I have a block of multiple lines like below say module 1 to module 100 ***** MAKING > module1 ************** kvmfkvmmfdv svksmnvlksmfvks dcsdvcs sddvcsv ssvsdvdf error: abcdefghi wrw wvsv dsvds sdvsd error:... (5 Replies)
Discussion started by: ganga.dharan
5 Replies

5. Shell Programming and Scripting

Print lines after the search string until blank line is found

All I want is to look for the pattern in the file...If I found it at # places... I want print lines after those pattern(line) until I find a blank line. Log EXAMPLE : MT:Exception caught The following Numbers were affected: 1234 2345 2346 Error java.lang.InternalError:... (3 Replies)
Discussion started by: prash184u
3 Replies

6. Shell Programming and Scripting

search and delete the lines in a file

HI group members I am new in unix I want to search # symbol in a file. if found need to delete the entire row in the file. need to move the actual data(with out # symbol data) to another file. Thanks (2 Replies)
Discussion started by: pmreddy
2 Replies

7. Shell Programming and Scripting

Delete a set of lines from a file

Hi All, Am very new for this Shell scripting. Could anyone pls let me know how to delete a set of lines from a (.DAT) file using ksh script. for example from line 3 to line 7. The size of the target file is huge:( ---------- Post updated at 11:01 PM ---------- Previous update was at 11:00 PM... (5 Replies)
Discussion started by: kasthu12
5 Replies

8. Shell Programming and Scripting

Deleting Multiple Lines in a File1 using critera found from File 2

Hi Everyone! I would like ask if there's a better way I can delete multiple lines in a file1 by collecting all criteria from file2. file1: a b c d e f file2: a e f The expected value will be: b (3 Replies)
Discussion started by: zzavilz
3 Replies

9. Shell Programming and Scripting

Search a character and replace it with multiple lines

This is for AIX 6.1, I've a flat file and the format is like this DECLARE some statements; BEGIN some statements; END; I've to search BEGIN and replace it with the following 4 lines BEGIN For x in 1..1 LOOP BEGIN Similarly I've to search END and replace it with the... (7 Replies)
Discussion started by: Mukul Sharma
7 Replies

10. UNIX for Beginners Questions & Answers

Delete multiple lines between blank lines containing two patterns

Hi all, I'm looking for a way (sed or awk) to delete multiple lines between blank lines containing two patterns ex: user: alpha parameter_1 = 15 parameter_2 = 1 parameter_3 = 0 user: alpha parameter_1 = 15 parameter_2 = 1 parameter_3 = 0 user: alpha parameter_1 = 16... (3 Replies)
Discussion started by: ce9888
3 Replies
Locale::Codes::LangExt(3)				User Contributed Perl Documentation				 Locale::Codes::LangExt(3)

NAME
Locale::Codes::LangExt - standard codes for language extension identification SYNOPSIS
use Locale::Codes::LangExt; $lext = code2langext('acm'); # $lext gets 'Mesopotamian Arabic' $code = langext2code('Mesopotamian Arabic'); # $code gets 'acm' @codes = all_langext_codes(); @names = all_langext_names(); DESCRIPTION
The "Locale::Codes::LangExt" module provides access to standard codes used for identifying language extensions, such as those as defined in the IANA language registry. Most of the routines take an optional additional argument which specifies the code set to use. If not specified, the default IANA language registry codes will be used. SUPPORTED CODE SETS
There are several different code sets you can use for identifying language extensions. A code set may be specified using either a name, or a constant that is automatically exported by this module. For example, the two are equivalent: $lext = code2langext('acm','alpha'); $lext = code2langext('acm',LOCALE_LANGEXT_ALPHA); The codesets currently supported are: alpha This is the set of three-letter (lowercase) codes from the IANA language registry, such as 'acm' for Mesopotamian Arabic. This is the default code set. ROUTINES
code2langext ( CODE [,CODESET] ) langext2code ( NAME [,CODESET] ) langext_code2code ( CODE ,CODESET ,CODESET2 ) all_langext_codes ( [CODESET] ) all_langext_names ( [CODESET] ) Locale::Codes::LangExt::rename_langext ( CODE ,NEW_NAME [,CODESET] ) Locale::Codes::LangExt::add_langext ( CODE ,NAME [,CODESET] ) Locale::Codes::LangExt::delete_langext ( CODE [,CODESET] ) Locale::Codes::LangExt::add_langext_alias ( NAME ,NEW_NAME ) Locale::Codes::LangExt::delete_langext_alias ( NAME ) Locale::Codes::LangExt::rename_langext_code ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangExt::add_langext_code_alias ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangExt::delete_langext_code_alias ( CODE [,CODESET] ) These routines are all documented in the Locale::Codes::API man page. SEE ALSO
Locale::Codes The Locale-Codes distribution. Locale::Codes::API The list of functions supported by this module. http://www.iana.org/assignments/language-subtag-registry The IANA language subtag registry. AUTHOR
See Locale::Codes for full author history. Currently maintained by Sullivan Beck (sbeck@cpan.org). COPYRIGHT
Copyright (c) 2011-2013 Sullivan Beck This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.16.3 2013-02-27 Locale::Codes::LangExt(3)
All times are GMT -4. The time now is 02:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy