Inserting a ' at the end of each line


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Inserting a ' at the end of each line
# 1  
Old 04-30-2010
Inserting a ' at the end of each line

Hi all,

I can use the following command to insert a ' at the beginning of each line

Code:
 sed "s/^/'/g" test.txt > test1.txt

However, I'm unable to use the following to insert a ' at the end of each line in this way

Code:
   sed "s/$/'/g" test.txt > test1.txt

Any help would be greatly appreciated. Thanks!

Last edited by vgersh99; 04-30-2010 at 02:47 PM.. Reason: code tags, please!
# 2  
Old 04-30-2010
Quote:
Originally Posted by karthiknaidu
Hi all,

I can use the following command to insert a ' at the beginning of each line

Code:
 sed "s/^/'/g" test.txt > test1.txt

However, I'm unable to use the following to insert a ' at the end of each line in this way

Code:
   sed "s/$/'/g" test.txt > test1.txt

Any help would be greatly appreciated. Thanks!
Code:
sed "s/$/'/g" test.txt > test1.txt

works just fine under Solaris.
# 3  
Old 04-30-2010
It's strange but the same thing works well in bash. Can anyone tell me why?
Thanks!
# 4  
Old 04-30-2010
Quote:
Originally Posted by karthiknaidu
It's strange but the same thing works well in bash. Can anyone tell me why?
Thanks!
should not be shell-dependent.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Inserting a blank line at the end of a .txt file?

Hi there, I am having this problem: a) I am uploading a txt file from windows (notepad) with some Gaussian 09 command lines; b) Gaussian needs in certain command files, that those files have a blank line at the end of the file! c) I open the command file with vi and no blank line at the of... (2 Replies)
Discussion started by: luismga
2 Replies

2. UNIX for Dummies Questions & Answers

Inserting new line

Hi all, I want ot print a header with new line in the end. I am using echo like echo "this is header" I want output like This is header $ I tried -e also but it's not working. echo - e Can anyone help please? (6 Replies)
Discussion started by: dsa
6 Replies

3. Shell Programming and Scripting

Inserting semicolon at the end of a line

HI Am totally confused with sed and translate command command.. My problem is I have a file like # vi test.csv ABC_IMUY ERD0_FN VEG_NON_DES_IYT BUY4_FLOW POI_SHD_URDF_IYUT_REDS_CYC UYT_PMC4_WIND EX_FRE_FRD_L2_REF_FLICT JHY_SGT_DSE_L2 IYO_HYTR_FGT_L3_BGT_ICT... (5 Replies)
Discussion started by: Priya Amaresh
5 Replies

4. Shell Programming and Scripting

Commenting a specific line and inserting a new line after commented line.

Hello All, I have following file contents cat file #line=aaaaaa #line=bbbbbb #line=cccccc #line=dddddd line=eeeeee #comment=11111 #comment=22222 #comment=33333 #comment=44444 comment=55555 Testing script Good Luck! I would like to comment line line=eeeeee and insert a new line... (19 Replies)
Discussion started by: manishdivs
19 Replies

5. Shell Programming and Scripting

Help with inserting a line

Hello, I am new to this forum. I have a question in Unix shell scripting. Here is my requirement I have 1000 files and I need to insert a header with one line at the top of each of the 1000 files. Please let me know if you have any solution for this Thanks in advance. Raj (4 Replies)
Discussion started by: trajashekar
4 Replies

6. Shell Programming and Scripting

Inserting a line in a file after every alternate line

Friends , I have a large file and i need to insert a line after every line.I am actually unaware how to do it.Any help appreciated. My File control station *ATM* , qread $OSS.Jul13A.FI01 interval 1 intcount 1 control station *ATM* , qread $OSS.Jul13A.FI02 interval 1 intcount... (4 Replies)
Discussion started by: appu2176
4 Replies

7. UNIX for Dummies Questions & Answers

Inserting control characters at the end of each line

How to add control characters at the end of each line in a file? Can anyone help me with this? Thanks, Shobana (2 Replies)
Discussion started by: Shobana_s
2 Replies

8. Shell Programming and Scripting

Inserting a line at the end

Hi All, I am using the below script to enter the URL at the end of file: echo "Enter the URL that should point to the particular microsite" read url sed "$a $url" redirects.virgin-atlantic.com.conf > temp But am getting the below error: ./script.sh:... (7 Replies)
Discussion started by: Shazin
7 Replies

9. UNIX for Advanced & Expert Users

Inserting a line before the line which matches the patter

Hi Is there any command where we can insert a line "2|||" before every line starting with "3|" my input is as follows 1|ETG|12345 3|79.58|||GBP|| 1|ETG|12345 3|79.58|||GBP|| 1|ETG|12345 2|EN_GB||Electrogalvanize 0.5 m2 ( Renault ) 1|ETG|12345 3|88.51|||GBP|| desired output... (10 Replies)
Discussion started by: laxmi131
10 Replies

10. Shell Programming and Scripting

Inserting a new line

I have a file where each line starts with a "update" statement. I want to insert a new line, after each line, with the words "go" in the new line. Can someone help me out with this? (1 Reply)
Discussion started by: ssmallya
1 Replies
Login or Register to Ask a Question