Sponsored Content
Top Forums Shell Programming and Scripting Using sed to insert text file at first line Post 302508762 by ctsgnb on Tuesday 29th of March 2011 03:44:49 AM
Old 03-29-2011
H appen newline + patternspace into the hold space
h would replace instead of appen
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SED- Insert text at top of file

Does anyone know how to insert text at the top and bottom of a file using sed? (12 Replies)
Discussion started by: MBGPS
12 Replies

2. Shell Programming and Scripting

Insert text file at a certain line.

I need to insert a file called temp_impact (which has about 15 lines in it) to a file called 11.23cfg starting at line 33. I searched the forums and found the sed '34i\ test' 11.23cfg > newfile That will enter word test at the appropriate line, but i need the entire file dumped there. Any... (4 Replies)
Discussion started by: insania
4 Replies

3. Shell Programming and Scripting

How to insert some constant text at beginig of each line within a text file.

Dear Folks :), I am new to UNIX scripting and I do not know how can I insert some text in the first column of a UNIX text file at command promtp. I can do this in vi editor by using this command :g/^/s//BBB_ e,g I have a file named as Test.dat and it containins below text: michal... (4 Replies)
Discussion started by: Muhammad Afzal
4 Replies

4. Shell Programming and Scripting

Need to insert new text and change existing text in a file using SED

Hi all, I need to insert new text and change existing text in a file. For that I used the below line in the command line and got the expected output. sed '$a\ hi... ' shell > shell1 But I face problem when using the same in script. It is throwing the error as, sed: command garbled:... (4 Replies)
Discussion started by: iamgeethuj
4 Replies

5. Shell Programming and Scripting

sed insert text at particular line

I know that sed -n '12p' file will print line 12 but how might I insert text to a specified line? thanks (2 Replies)
Discussion started by: action_owl
2 Replies

6. Shell Programming and Scripting

Insert text file only after the first match with SED

Hello, I'm new in Shell scripting but i should write a script, which inserts the license header out of a txt-File into the files in our Projekt. For the Java classes it runs without Problems but for XML files not. At xml-files i have to put the license Header after the xml-Header (?xml... (1 Reply)
Discussion started by: PhoenixONE
1 Replies

7. Shell Programming and Scripting

Sed insert text at first line of empty file

I can't seem to get sed to allow me to insert text in the first line of an empty file. I have a file.txt that is a 0 byte file. I want sed to insert " fooBar" onto the first line. I've tried a few options and nothing seems to work. They work just fine if there's text in the file tho. Help? (4 Replies)
Discussion started by: DC Slick
4 Replies

8. UNIX for Dummies Questions & Answers

Insert a line in a text file

I want to insert a line with text after the 9th line of a text file. How would I do this using sed or awk? (2 Replies)
Discussion started by: lost.identity
2 Replies

9. Shell Programming and Scripting

How to read a text file line by line and insert into a database table?

I have a test file that I want to read and insert only certain lines into the the table based on a filter. 1. Rread the log file 12 Hours back Getdate() -12 Hours 2. Extract the following information on for lines that say "DUMP is complete" A. Date B. Database Name C.... (2 Replies)
Discussion started by: JolietJake
2 Replies

10. UNIX for Beginners Questions & Answers

Insert a line of text on nth line of a file

Hi All, I am using UNix Sun OS sun4u sparc SUNW,SPARC-Enterprise My intention is to insert a line of text after 13th line of every file inside a particular directory. While trying to do it for a single file , i am using sed sed '3 i this is the 4th line' filename sed: command garbled: 3... (5 Replies)
Discussion started by: gotamp
5 Replies
WebService::CIA::Source::Web(3pm)			User Contributed Perl Documentation			 WebService::CIA::Source::Web(3pm)

NAME
WebService::CIA::Source::Web - An interface to the online CIA World Factbook SYNOPSIS
use WebService::CIA::Source::Web; my $source = WebService::CIA::Source::DBM->new(); DESCRIPTION
WebService::CIA::Source::Web is an interface to the live, online version of the CIA World Factbook. It's a very slow way of doing things, but requires no pre-compiled DBM. It's more likely to be useful for proving concepts or testing. METHODS
Apart from "new", these methods are normally accessed via a WebService::CIA object. "new( \%opts )" my $source = WebService::CIA::Source::Web->new(); $source = WebService::CIA::Source::Web->new( { user_agent => $ua } ); This method creates a new WebService::CIA::Source::Web object. It takes an optional hashref of arguments. "user_agent" A user agent object to use. This must implement the same user interface as "LWP::UserAgent" (or, at least, a "get()" method). "value($country_code, $field)" Retrieve a value from the web. $country_code should be the FIPS 10-4 country code as defined in <https://www.cia.gov/library/publications/the-world-factbook/appen- dix/appendix-d.html>. $field should be the name of the field whose value you want to retrieve, as defined in <https://www.cia.gov/library/publica- tions/the-world-factbook/docs/notesanddefs.html>. (WebService::CIA::Parser also creates four extra fields: "URL", "URL - Print", "URL - Flag", and "URL - Map" which are the URLs of the country's Factbook page, the printable version of that page, a GIF map of the coun- try, and a GIF flag of the country respectively.) "value" will return "undef" if the country or field cannot be found, or if there is an error GETing the page. This isn't ideal, but I can't think of the best way around it right now. "all($country_code)" Returns a hashref of field-value pairs for $country_code or an empty hashref if $country_code isn't available from the Factbook. "get($country_code)" Retrieve and cache the data for a country. Returns 1 if successful, 0 if not. "cached($country_code)" Get/set the country code whose data is cached. "cache($hashref)" Get/set a hashref of data for the current country. "parser()" Returns a reference to the WebService::CIA::Parser object being used. "ua( $userAgent )" Returns a reference to the user agent object being used. By default this is an "LWP::UserAgent" object, but you can pass a different object in if you wish. "last_response()" Returns the "HTTP::Response" object from the last request. CACHING
In order to make some small improvement in efficiency, WebService::CIA::Source::Web keeps a copy of the data for the last country down- loaded in memory. TO DO
File system based caching of pages. User-definable stack of cached countries, rather than just one. Caching of last-modified headers; conditional GET. AUTHOR
Ian Malpass (ian-cpan@indecorous.com) COPYRIGHT
Copyright 2003-2007, Ian Malpass This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The CIA World Factbook's copyright information page (<https://www.cia.gov/library/publications/the-world-factbook/docs/contributor_copy- right.html>) states: The Factbook is in the public domain. Accordingly, it may be copied freely without permission of the Central Intelligence Agency (CIA). SEE ALSO
WebService::CIA, WebService::CIA::Parser, WebService::CIA::Source::DBM perl v5.8.8 2008-02-04 WebService::CIA::Source::Web(3pm)
All times are GMT -4. The time now is 11:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy