Sponsored Content
Top Forums Shell Programming and Scripting Adding lines at end of a line Post 302421633 by Ernst on Saturday 15th of May 2010 10:43:47 AM
Old 05-15-2010
Adding lines at end of a line

This is what I want to do. I want to write a script that reads each line (of the highlighted file below) and add a specific number of blank lines (sometime 2, 3 or 5 lines) at the end of each line while copying that line. For example, here is the input.

Code:
The sky is blue.
I like to eat.
I like nice cars.
staying healthy is fun.

I want this as my output:
Code:
The sky is blue.
The sky is blue.
The sky is blue.
I like to eat.
I like to eat.
I like to eat.
I like to eat.
I like nice cars.
staying healthy is fun.
staying healthy is fun.
staying healthy is fun.
staying healthy is fun.
staying healthy is fun.

I already tried this script:
Code:
while read line
do 
echo $line "\n \n"
done< filename

My output gave me a couple of blank lines but do not know how to add a copy of each line to those blank lines.

I hope someone can help.

Thank you!

Last edited by Scott; 05-15-2010 at 10:32 PM.. Reason: code tags...
 

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
funparamput(3)							SAORD Documentation						    funparamput(3)

NAME
FunParamPut - put a Funtools param value SYNOPSIS
#include <funtools.h> int FunParamPutb(Fun fun, char *name, int n, int value, char *comm, int append) int FunParamPuti(Fun fun, char *name, int n, int value, char *comm, int append) int FunParamPutd(Fun fun, char *name, int n, double value, int prec, char *comm, int append) int FunParamPuts(Fun fun, char *name, int n, char *value, char *comm, int append) DESCRIPTION
The four routines FunParamPutb(), FunParamPuti(), FunParamPutd(), and FunParamPuts(), will set the value of a FITS header parameter as a boolean, int, double, and string, respectively. The first argument is the Fun handle associated with the FITS header being accessed. Normally, the header is associated with the FITS extension that you opened with FunOpen(). However, you can use FunInfoPut() to specify that use of the primary header. In particular, if you set the FUN_PRIMARYHEADER parameter to 1, then the primary header is used for all parameter access until the value is reset to 0. For example: int val; FunParamPuti(fun, "NAXIS1", 0, 10, NULL, 1); # current header val=1; FunInfoPut(fun, FUN_PRIMARYHEADER, &val, 0); # switch to ... FunParamPuti(fun, "NAXIS1", 0, 10, NULL, 1); # primary header (You also can use the deprecated FUN_PRIMARY macro, to access parameters from the primary header.) The second argument is the name of the parameter. ( In accordance with FITS standards, the special names COMMENT and HISTORY, as well as blank names, are output without the "= " value indicator in columns 9 and 10. The third n argument, if non-zero, is an integer that will be added as a suffix to the parameter name. This makes it easy to use a simple loop to process parameters having the same root name. For example, to set the values of TLMIN and TLMAX for each column in a binary table, you can use: for(i=0; i<got; i++){ FunParamPutd(fun, "TLMIN", i+1, tlmin[i], 7, "min column val", 1); FunParamPutd(fun, "TLMAX", i+1, tlmax[i], 7, "max column val", 1); } The fourth defval argument is the value to set. Note that the data type of this argument is different for each specific FunParamPut() call. The comm argument is the comment string to add to this header parameter. Its value can be NULL. The final append argument determines whether the parameter is added to the header if it does not exist. If set to a non-zero value, the header parameter will be appended to the header if it does not exist. If set to 0, the value will only be used to change an existing parameter. Note that the double precision routine FunParamPutd() supports an extra prec argument after the value argument, in order to specify the precision when converting the double value to ASCII. In general a 20.[prec] format is used (since 20 characters are alloted to a floating point number in FITS) as follows: if the double value being put to the header is less than 0.1 or greater than or equal to 10**(20-2-[prec]), then %20.[prec]e format is used (i.e., scientific notation); otherwise %20.[prec]f format is used (i.e., numeric nota- tion). As a rule, parameters should be set before writing the table or image. It is, however, possible to update the value of an existing parame- ter after writing an image or table (but not to add a new one). Such updating only works if the parameter already exists and if the output file is seekable, i.e. if it is a disk file or is stdout being redirected to a disk file. It is possible to add a new parameter to a header after the data has been written, but only if space has previously been reserved. To reserve space, add a blank parameter whose value is the name of the parameter you eventually will update. Then, when writing the new param- eter, specify a value of 2 for the append flag. The parameter writing routine will first look to update an existing parameter, as usual. If an existing parameter is not found, an appropriately-valued blank parameter will be searched for and replaced. For example: /* add blank card to be used as a place holder for IPAR1 update */ FunParamPuts(fun, NULL, 0, "IPAR1", "INTEGER Param", 0); ... /* write header and data */ FunTableRowPut(fun, events, got, 0, NULL); ... /* update param in file after writing data -- note append = 2 here */ FunParamPuti(fun, "IPAR", 1, 400, "INTEGER Param", 2); The parameter routines return a 1 if the routine was successful and a 0 on failure. In general, the major reason for failure is that you did not set the append argument to a non-zero value and the parameter did not already exist in the file. SEE ALSO
See funtools(7) for a list of Funtools help pages version 1.4.2 January 2, 2008 funparamput(3)
All times are GMT -4. The time now is 09:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy