Put three points at the end of a line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Put three points at the end of a line
# 1  
Old 10-16-2013
Put three points at the end of a line

Hello
I have a file like this
Code:
Anyway, if you are sincere
in finding the druid Alcuin

then you're going to need ships.

die with the faith that you
have stood shield to shield

with your brothers.

To honour, to glory, to a valiant death

and then on to the hall of heroes. Skal!

And I want the file like this
Code:
Anyway, if you are sincere
in finding the druid Alcuin...

then you're going to need ships.

die with the faith that you
have stood shield to shield...

with your brothers.

To honour, to glory, to a valiant death...

and then on to the hall of heroes. Skal!

I want to put three points(...) after Alcuin shield and death.
I know how to do it for every line who ends on a letter.
Code:
sed 's/[a-z]$/&.../g'  file

But this put also the points after sincere and you.
But that cannot.
I don't want the three points om the first line between two empty lines,
only on the last line between two empty lines.
Thanks

Last edited by Scrutinizer; 10-16-2013 at 05:08 PM.. Reason: Code tags, please...
# 2  
Old 10-16-2013
An awk solution:
Code:
awk '{ if ($0 ~ /[[:alpha:]]$/) {print $0 "..."} else {print} }' RS="" ORS="\n\n" file

These 2 Users Gave Thanks to CarloM For This Post:
# 3  
Old 10-16-2013
Quote:
Originally Posted by thailand
I want to put three points(...) after Alcuin shield and death.
I know how to do it for every line who ends on a letter.
sed 's/[a-z]$/&.../g' file
But this put also the points after sincere and you.
But that cannot.
I don't want the three points om the first line between two empty lines,
only on the last line between two empty lines.
Thanks
How about doing it for each keyword...
Code:
sed -e 's/Alcuin$/&.../' -e 's/shield$/&.../' -e 's/death$/&.../' file

This User Gave Thanks to shamrock For This Post:
# 4  
Old 10-16-2013
Nice solution CarloM, it can be simplified slightly:

Code:
awk '/[[:alpha:]]$/ {$0=$0 "..."}1' RS="" ORS="\n\n" infile2

These 2 Users Gave Thanks to Chubler_XL For This Post:
# 5  
Old 10-17-2013
I'm gone try this possible solutions but I can't use the solution from shamrock because the words are examples so in every file I have different words but anyway thanks.

---------- Post updated 10-17-13 at 12:01 AM ---------- Previous update was 10-16-13 at 10:29 PM ----------

P { margin-bottom: 0.21cm; } Hello

The solutions that you give me doesn't work on my computer but I
try now this :
awk '{ if ($0 ~ /[a-z]$/) {print $0"..."} else {print $0} }' file
(but that is the same like the solution with sed :sed 's/[a-z]$/&.../g' file)
en this works but he put the three points on every line who ends with a
letter.
The problem is that he can put only on the last line between two empty
lines. So when I have only one line between two empty lines he must do it.
When I have two lines between two empty lines he must take only the last line.
example



To honour, to glory, to a valiant death


and then on to the hall of heroes. Skal!


Why don't you just give
Lord Beothric what he wants?


die with the faith that you
have stood shield to shield


with your brothers.


In this example he must put only after the words “ death shield “ the three points
and not after “give you”.
The empty lines are imported and they cannot away.
So the output must be like this


To honour, to glory, to a valiant death...


and then on to the hall of heroes. Skal!


Why don't you just give
Lord Beothric what he wants?


die with the faith that you
have stood shield to shield ...


with your brothers.
Thanks
# 6  
Old 10-17-2013
It doesn't work because you missed out part of the command:
Code:
awk '{ if ($0 ~ /[a-z]$/) {print $0"..."} else {print $0} }' RS="" ORS="\n\n" file

Also, please use [code] tags - it makes your code and data a lot easier to use.
This User Gave Thanks to CarloM For This Post:
# 7  
Old 10-17-2013
hello
this code do the thing
awk '{ if ($0 ~ /[a-z]$/) {print $0"..."} else {print $0} }' RS="" ORS="\n\n" file
thanks for the help.
I want to close this thread but don't know how?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to use sed to put string end of line?

I have several file as below, and i want to put .txt to specific text contain ^main=EXE^cmd=run script /usr/prog/bd_, file1 7.9102 12.1528 16.3672 7.4002 ^main=EXE^cmd=run script /usr/prog/bd_123^" line 16.3672 7.3134 17.8711 6.0981 file 2 7.9102 12.1528 16.3672 7.4002 ... (8 Replies)
Discussion started by: zulabc
8 Replies

2. Shell Programming and Scripting

Using sed to put text end of line

how to use sed to put .txt end of line..my input file below file1 make=^bak12^". DEV=LONG^cmd/usr/bak/ade4^" ..................................... file 2 make=^and_LONG/bak12^". DEV=LONG^cmd/usr/bak/ban3^" .......................................... file 3... (6 Replies)
Discussion started by: zulabc
6 Replies

3. Shell Programming and Scripting

Remove line based on string and put new line with parameter

Hi Folks, I am new to ksh, i have informatica parameter file that i need to update everyday with shell script. i need your help updating this file with new parameters. sample data $$TABLE1_DATE=04-27-2011 $$TABLE2_DATE=04-23-2011 $$TABLE3_DATE=03-19-2011 .......Highligned... (4 Replies)
Discussion started by: victor369
4 Replies

4. Shell Programming and Scripting

put string end of the line

I've a problem to put .h end of the line..below my input file fg_a bb fg_b bb fg_c bb fg_d aa fg_f ee and i want the output file as below fg_a.h bb fg_b.h bb fg_c.h bb fg_d.h (6 Replies)
Discussion started by: zulabc
6 Replies

5. Shell Programming and Scripting

How to put count for first element in a file at the end

Hi, I have a file where I need to count the total for the first element and put it back at the end of file... here is the example... input.. FHDR|ABC|20100607| |ABC|8453|CDE|E166|||| 123|ABC|8453|CDE|E166|||| 123|ABC|8453|CDE|E166|||| 111|ABC|8453|CDE|E166||||... (8 Replies)
Discussion started by: donadarsh
8 Replies

6. Shell Programming and Scripting

Interpolating on a line between to points

I have two points which represent the start and end points of a line. I need to interpolate a number of points on the line between the two points. Point 1: x = 455989.0 y = 8673453.4 Point 2: x = 283957.6 y = 8691250.1 The two points I have are coordinates given in UTM format. x... (3 Replies)
Discussion started by: mattings
3 Replies

7. Shell Programming and Scripting

to put date at the end of each line

#!/bin/ksh if test -f file6.txt then rm file6.txt fi a=`date +"%F"` awk '{print $0,"$a"}' file3.txt > file6.txt ----------------------------------------------------------------- i need to append date at the end of each line in file 3 and o/p it to file6.txt (3 Replies)
Discussion started by: ali560045
3 Replies

8. UNIX and Linux Applications

Gnuplot question: how to plot 3D points as colored points in map view?

I have a simple gnuplot question. I have a set of points (list of x,y,z values; irregularly spaced, i.e. no grid) that I want to plot. I want the plot to look like this: - points in map view (no 3D view) - color of each point should depend on its z-value. - I want to define my own color scale -... (0 Replies)
Discussion started by: karman
0 Replies

9. Shell Programming and Scripting

how to put nil at the end of each records.

Hello, I have a file with 100,000 records. Each record have many fileds and used "," to split (like below): 0100,apple,john,2233,N,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,IDN, 0201,steve,2435,N,0,49,6.658,0,6.658,37.104302,0,0,0,0,0,37.104302,0,49,6.658,0,6.658,37.104302,UAE,AED... (2 Replies)
Discussion started by: happyv
2 Replies

10. Shell Programming and Scripting

put a semicolon at the end of each line of a file

hi, Consider there is a file containing 200 lines. please let me know which command is to be used to put a semicolon at the end of each line. if no single command is there then how it can be achieved. (1 Reply)
Discussion started by: surjyap
1 Replies
Login or Register to Ask a Question