insert period at the end of each line


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers insert period at the end of each line
# 1  
Old 11-18-2008
insert period at the end of each line

file1 contains:

this is a test
this is a test and only a test
this is another test
this is another test and only another only

i'd like my file to look like this:

this is a test.
this is a test and only a test.
this is another test.
this is another test and only another only.
# 2  
Old 11-18-2008
Code:
sed 's/$/\./'  my_input_filename  > newfilename

# 3  
Old 11-18-2008
jim,
thanks. i also found answer on this site as well.

cat <filename> | sed s/$/"\|"hello/g > new_file.txt
# 4  
Old 11-18-2008
jim,

i am new to shell script. $/\ = end of line, right ?

what if i want insert beginning of each line ?

thank you for your help.
# 5  
Old 11-18-2008
^ - start
$ - end
# 6  
Old 11-18-2008
Ikon,

thank you much.
# 7  
Old 11-18-2008
using Perl:
Code:
perl -pi -e 's/$/\./' filename

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Print one sentence 40 to 50 words end with period in a file

Hi All, Is there another way to achieve this? how get short phrase in a sentence with character count of 100 to 155 words end with period but don't end something like 50,000. . Here's my current script but the output is not good. This will use for my snippets or preview. grep... (6 Replies)
Discussion started by: lxdorney
6 Replies

2. Shell Programming and Scripting

Line count of trace files for 24 period

Hi, Using solaris 10 5.10 o/s I am learning awk as I work here on the job. What I need to do is isolate the trace file for the last 24 hours. After that I need to open those trace files and search for 'TNS-|ORA-' message from each one. These trace files MAY HAVE an occurance of them. I... (5 Replies)
Discussion started by: bdby
5 Replies

3. 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

4. Shell Programming and Scripting

How to insert period after each number?

stupid question: trying to use sed to do the following... $ echo '12345' | sed 's/./&./g' 1.2.3.4.5. needed this instead: 1.2.3.4.5 but how? please advise (7 Replies)
Discussion started by: ux4me
7 Replies

5. UNIX for Dummies Questions & Answers

insert string at end of line if it found from list

Hi all, can some one help me out file 1 i have 06/01 3:14 d378299 06/01 8:10 d642036 06/01 10:51 d600441 06/01 10:52 d600441 06/01 11:11 d607339 06/01 11:49 d398706 something like this and in file named list i have ( there is space btwn 06/01 and 11:49 and d398706) d607339... (5 Replies)
Discussion started by: zozoo
5 Replies

6. Shell Programming and Scripting

gawk (dos) insert backslash at end of line

I have created with the DOS-command dir a list of a directory. Directory of C:\Users\User\Documents 09.06.2011 20:50 48.322 file1.txt 02.11.2010 23:00 9.216 file2.txt 15.12.2010 21:06 26.793 file2.txt Now i would like to add the directory ahead of the filename. Therefore a... (6 Replies)
Discussion started by: sdf
6 Replies

7. Shell Programming and Scripting

insert text at every end of the line

Hi, I just wanted to know if you have any idea or script to insert a text at everyend of the line, the text will vary. for example sample: this is line1 ok this is line2 ok this is line3 ok output: this is line1 ok /home/line1.txt this is line2 ok /home/line2.txt this is line3 ok... (6 Replies)
Discussion started by: invinzin21
6 Replies

8. Shell Programming and Scripting

Insert two strings at the beginning and at the end of each line of a file

Hi, excuse me for my poor english. My problem is that: I have a File i want to add to each line of that file two strings: one at the beginning of the line, one at the ending. string1="abcd" string2="efgh" i want $string1 content $string2 for each line. Is that possible? (3 Replies)
Discussion started by: Linux-fueled
3 Replies

9. UNIX for Dummies Questions & Answers

How can I insert character to end of file?

Hello all How can I insert character to the end of text file without opening it in vi Just simple one liner, can it be done? Tnx (1 Reply)
Discussion started by: umen
1 Replies

10. Shell Programming and Scripting

How to insert a string at the end of a file read

Hi, This thread is an extension of the post I posted in another folder for Unix Dummies. I am actually trying to read all the files in a folder, let say folder A. There are alot of .txt files in this folder where I have sed them and translate to numeric elements. For example:- I have... (5 Replies)
Discussion started by: ahjiefreak
5 Replies
Login or Register to Ask a Question