The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 07-17-2006
Registered User
 

Join Date: Jul 2006
Posts: 6
Pls Ans this question ...

In the Text file ex sample.txt

cat sample.txt

morning
evening
night
bye

__________________
i want add text "Good " i front of all the words .
u have to use one vi command only
or
u can write script also

o/p should be like this

cat sample.txt
Good morning
Good evening
Good night
Good bye

___________
Reply With Quote
Forum Sponsor
  #2  
Old 07-17-2006
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,698
Show us what you have tried so far ? Maybe we could help you out better.
Reply With Quote
  #3  
Old 07-17-2006
tayyabq8's Avatar
Moderator
 

Join Date: Nov 2004
Location: Bahrain
Posts: 555
Code:
awk '{printf "%s%s\n", "Good ", $0}' sample.txt
Reply With Quote
  #4  
Old 07-17-2006
aigles's Avatar
Registered User
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,212
Another way to t do the work :
Code:
sed 's/^/Good /' sample.txt
Reply With Quote
  #5  
Old 07-17-2006
Registered User
 

Join Date: Jul 2006
Posts: 6
Thanks for replay ...

pls let me know . Whether we can do in VI Editor or not ..
Reply With Quote
  #6  
Old 07-17-2006
aigles's Avatar
Registered User
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,212
in vi editor

Code:
:%s/^/Good/g
Jean-Pierre.
Reply With Quote
  #7  
Old 07-17-2006
Hitori's Avatar
Registered User
 

Join Date: Jun 2006
Posts: 360
also in vi(m) type
g g C+v M+g M+i, type 'Good ', then Esc
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 11:23 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0