Sponsored Content
Top Forums Shell Programming and Scripting Adding specific text and spaces to each line in a text file Post 302228821 by hertingm on Monday 25th of August 2008 02:03:35 PM
Old 08-25-2008
Adding specific text and spaces to each line in a text file

Hi,

I wanted to add specific text to each row in a text file containing three rows. Example:

0 8 7 6 5 5
7 8 9 0 7 9
7 8 9 0 1 2

And I want to add a 21 at the beginning of the first row, and blank spaces at the beginning of the second two rows. To get this:

21 0 8 7 6 5 5
7 8 9 0 7 9
7 8 9 0 1 2

Thanks in advance!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Adding Text To each line of a file

How would I add text to the beginning of each line in a text file in a script right after the file is created from another text file. (4 Replies)
Discussion started by: cubs0729
4 Replies

2. Shell Programming and Scripting

adding text to end of each line in a file

I'm needing to add a "hour:min" to the end of each line in a document. The document in this case is only going to be one line. if this inserts it at the end, what needs to be changed to add something at the end... /bin/echo "%s/^/$filler/g\nwq!" | ex -s $oFile Thank you... (2 Replies)
Discussion started by: cubs0729
2 Replies

3. Shell Programming and Scripting

adding new line after finding specific text

hello i need some help here are the contents of my file. test.txt this is filename 1.mp3 http://www.url.com/filenamehashed filename 2.mp3 http://www.url.com/fileamehashed something_else.zip http://www.url.com/filenamehashed so this file has 100 of these lines filename url I would... (9 Replies)
Discussion started by: mscice
9 Replies

4. Shell Programming and Scripting

[bash help]Adding multiple lines of text into a specific spot into a text file

I am attempting to insert multiple lines of text into a specific place in a text file based on the lines above or below it. For example, Here is a portion of a zone file. IN NS ns1.domain.tld. IN NS ns2.domain.tld. IN ... (2 Replies)
Discussion started by: cdn_humbucker
2 Replies

5. Shell Programming and Scripting

adding a line to a text file

I have a tab delimited text file, id name distance 1 3325167 0.334561754018 2 3290488 0.389444269458 3 3288794 0.392312701782 4 3347602 0.392532202097 5 3295355 0.394394169485 I need to add a line after the header line. The first and third field of... (3 Replies)
Discussion started by: LMHmedchem
3 Replies

6. UNIX for Dummies Questions & Answers

Adding tags to a specific column of a space delimited text file

I have a space delimited text file with two columns. I would like to add NA to the first column of the text file. Input: 19625 10.4791768259 19700 10.8146489183 19701 10.9084026759 19702 10.9861346978 19703 10.9304364984 Output: NA19625 10.4791768259 NA19700 10.8146489183... (1 Reply)
Discussion started by: evelibertine
1 Replies

7. Shell Programming and Scripting

Adding text to the end of the specific line in a file(only to the first occurrence of it)

Hi, I want to add a text to the end of the specific line in a file. Now my file looks like this: 999 111 222 333 111 444 I want to add the string " 555" to the end of the first line contaning 111. Moreover, I want to insert a newline after this line containg the "000" string. The... (8 Replies)
Discussion started by: wenclu
8 Replies

8. UNIX for Dummies Questions & Answers

[Help] Adding text to a variable line in a file

Hey guys, I need to write a script that will add a specific text at the end of a specific line (of a text file). but the line is a variable this is my text file : device_2 ansible_ssh_host=127.0.0.1 ansible_ssh_port=30000 ansible_ssh_user='root' device_2 ansible_ssh_host=127.0.0.1... (1 Reply)
Discussion started by: OdedOvdat
1 Replies

9. Shell Programming and Scripting

Extract specific line in an html file starting and ending with specific pattern to a text file

Hi This is my first post and I'm just a beginner. So please be nice to me. I have a couple of html files where a pattern beginning with "http://www.site.com" and ending with "/resource.dat" is present on every 241st line. How do I extract this to a new text file? I have tried sed -n 241,241p... (13 Replies)
Discussion started by: dejavo
13 Replies

10. UNIX for Beginners Questions & Answers

Tip to remove line endings and spaces on a pre-formatted text file?

Hi, At the moment, using Notepad++ to do a search and replace, manually section by section which is real painful. Yeah, so copying each section of the line of text and putting into a file and then search and replace, need at least 3-operations in Notepad++. Here's hoping I will be able to... (1 Reply)
Discussion started by: newbie_01
1 Replies
DBLINK_GET_RESULT(3)					  PostgreSQL 9.2.7 Documentation				      DBLINK_GET_RESULT(3)

NAME
dblink_get_result - gets an async query result SYNOPSIS
dblink_get_result(text connname [, bool fail_on_error]) returns setof record DESCRIPTION
dblink_get_result collects the results of an asynchronous query previously sent with dblink_send_query. If the query is not already completed, dblink_get_result will wait until it is. ARGUMENTS
conname Name of the connection to use. fail_on_error If true (the default when omitted) then an error thrown on the remote side of the connection causes an error to also be thrown locally. If false, the remote error is locally reported as a NOTICE, and the function returns no rows. RETURN VALUE
For an async query (that is, a SQL statement returning rows), the function returns the row(s) produced by the query. To use this function, you will need to specify the expected set of columns, as previously discussed for dblink. For an async command (that is, a SQL statement not returning rows), the function returns a single row with a single text column containing the command's status string. It is still necessary to specify that the result will have a single text column in the calling FROM clause. NOTES
This function must be called if dblink_send_query returned 1. It must be called once for each query sent, and one additional time to obtain an empty set result, before the connection can be used again. When using dblink_send_query and dblink_get_result, dblink fetches the entire remote query result before returning any of it to the local query processor. If the query returns a large number of rows, this can result in transient memory bloat in the local session. It may be better to open such a query as a cursor with dblink_open and then fetch a manageable number of rows at a time. Alternatively, use plain dblink(), which avoids memory bloat by spooling large result sets to disk. EXAMPLES
contrib_regression=# SELECT dblink_connect('dtest1', 'dbname=contrib_regression'); dblink_connect ---------------- OK (1 row) contrib_regression=# SELECT * FROM contrib_regression-# dblink_send_query('dtest1', 'select * from foo where f1 < 3') AS t1; t1 ---- 1 (1 row) contrib_regression=# SELECT * FROM dblink_get_result('dtest1') AS t1(f1 int, f2 text, f3 text[]); f1 | f2 | f3 ----+----+------------ 0 | a | {a0,b0,c0} 1 | b | {a1,b1,c1} 2 | c | {a2,b2,c2} (3 rows) contrib_regression=# SELECT * FROM dblink_get_result('dtest1') AS t1(f1 int, f2 text, f3 text[]); f1 | f2 | f3 ----+----+---- (0 rows) contrib_regression=# SELECT * FROM contrib_regression-# dblink_send_query('dtest1', 'select * from foo where f1 < 3; select * from foo where f1 > 6') AS t1; t1 ---- 1 (1 row) contrib_regression=# SELECT * FROM dblink_get_result('dtest1') AS t1(f1 int, f2 text, f3 text[]); f1 | f2 | f3 ----+----+------------ 0 | a | {a0,b0,c0} 1 | b | {a1,b1,c1} 2 | c | {a2,b2,c2} (3 rows) contrib_regression=# SELECT * FROM dblink_get_result('dtest1') AS t1(f1 int, f2 text, f3 text[]); f1 | f2 | f3 ----+----+--------------- 7 | h | {a7,b7,c7} 8 | i | {a8,b8,c8} 9 | j | {a9,b9,c9} 10 | k | {a10,b10,c10} (4 rows) contrib_regression=# SELECT * FROM dblink_get_result('dtest1') AS t1(f1 int, f2 text, f3 text[]); f1 | f2 | f3 ----+----+---- (0 rows) PostgreSQL 9.2.7 2014-02-17 DBLINK_GET_RESULT(3)
All times are GMT -4. The time now is 05:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy