Sponsored Content
Top Forums Shell Programming and Scripting Adding lines at end of a line Post 302421701 by Ernst on Saturday 15th of May 2010 08:29:28 PM
Old 05-15-2010
Actually, in this case, the number of lines will be arbitrary. I think I might have to number the rows first and tell the script the number of rows I need to add to a specific line. For example, I may want to add two lines to row 3 but 6 lines to row 4 and 8 lines to row 1. You get the idea.

By the way, I keep getting this error message when I run your script.
"
Code:
syntax error at line 9: `i=$' unexpected

"

---------- Post updated at 08:29 PM ---------- Previous update was at 07:22 PM ----------

Jim, I got closer by using this script:

Code:
nl testfile > testfile1
while read line
do
    echo $line "\n $line \n $line" >> sw1_LineInsert
done <testfile1

This script copies each line twice. This is not I really want. I need to figure out now how to tell the script the number of times I want to copy a specific row.

Let me know if you have any suggestions.

Thanks!

Last edited by Scott; 05-15-2010 at 10:33 PM.. Reason: Code tags, please...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Adding new line at the end of file

Hi I have few files. For some files the cursor is at the end of last line. For other files, cursor is at the new line at the end. I want to bring the cursor down to next line for the files that are having cursor at the end of last line In otherwords, I want to introduce a blank line at the... (5 Replies)
Discussion started by: somesh_p
5 Replies

2. Shell Programming and Scripting

adding semicolumn at end of line

Hi , I need to add semicolumn at the end of each line in a file. can any one help me in this? Thanks in advance (2 Replies)
Discussion started by: scorpio
2 Replies

3. Shell Programming and Scripting

adding text to the end of lines containing a word

I'm new to shell scripting, and need to add a series of commands to the ends of certain lines of text that contain a keyword. Any easy way to do this? Thanks (2 Replies)
Discussion started by: ironwall
2 Replies

4. Shell Programming and Scripting

adding characters end of line where line begins with..

Hi all, using VI, can anyone tell me how to add some characters onto the end of a line where the line begins with certain charactars eg a,b,c,......., r,s,t,........, a,b,c,......., all lines in the above example starting with a,b,c, I want to add an x at the end of the line so the... (6 Replies)
Discussion started by: satnamx
6 Replies

5. UNIX for Dummies Questions & Answers

Adding comma at the end of every line

Hi all, I have this sample file (actual file is larger) and i need to add comma at the end of every line. 1234 4335 232345 1212 3535 Output 1234, 4335, 232345, 1212, 3535, TIA - jak (2 Replies)
Discussion started by: jakSun8
2 Replies

6. Shell Programming and Scripting

Script adding ^M to end of line

I trying to make a simple script to get info from remote servers my problem is the output of this line- SERVER_NAME=`ssh -t $USER@$REMOTESERVER 'hostname'`the output is linux1^M I would like to remove the ^M where is my error? Many Thanks -Steve (1 Reply)
Discussion started by: shoodlum
1 Replies

7. Shell Programming and Scripting

Adding tab/new line at the end of each line of a file

Hello Everyone, I need a help from experts of this community regarding one of the issue that I am facing with shell scripting. My requirement is to append char's at the end of each line of a file. The char that will be appended is variable and will be passed through command line. The... (20 Replies)
Discussion started by: Sourav Das
20 Replies

8. Shell Programming and Scripting

Adding semicolon at the end of each line

Hi, I have a script which I need to change. I want to add a semicolon at the end of each line where the line starts with "grant" for e.g. create table(.... ); grant select on TABL1 to USER1 grant select on TABL1 to USER2should become create table(.... ); grant select on TABL1 to... (3 Replies)
Discussion started by: pparthiv
3 Replies

9. Shell Programming and Scripting

awk Adding a Period at the end of a line

I started venturing in learning the art of using AWK/GAWK and wanted to simply added a period from line #11 to line #28 or to the end of the file if there is data. So for example: 11 Centos.NM 12 dojo1 13 redhat.5.5.32Bit 14 redhat.6.2.64Bit... (5 Replies)
Discussion started by: metallica1973
5 Replies

10. Shell Programming and Scripting

Adding comma to end of each line if more than 1 line

I have a file with dates as '2013-01-01' '2013-01-02' I want the output to be '2013-01-01','2013-01-02' if there is only 1 entry then there should not be any comma. (6 Replies)
Discussion started by: ATWC
6 Replies
PG_NUM_ROWS(3)															    PG_NUM_ROWS(3)

pg_num_rows - Returns the number of rows in a result

SYNOPSIS
int pg_num_rows (resource $result) DESCRIPTION
pg_num_rows(3) will return the number of rows in a PostgreSQL result resource. Note This function used to be called pg_numrows(3). PARAMETERS
o $result - PostgreSQL query result resource, returned by pg_query(3), pg_query_params(3) or pg_execute(3) (among others). RETURN VALUES
The number of rows in the result. On error, -1 is returned. EXAMPLES
Example #1 pg_num_rows(3) example <?php $result = pg_query($conn, "SELECT 1"); $rows = pg_num_rows($result); echo $rows . " row(s) returned. "; ?> The above example will output: 1 row(s) returned. SEE ALSO
pg_num_fields(3), pg_affected_rows(3). PHP Documentation Group PG_NUM_ROWS(3)
All times are GMT -4. The time now is 08:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy