![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 ___________ |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Show us what you have tried so far ? Maybe we could help you out better.
|
|
#3
|
||||
|
||||
|
Code:
awk '{printf "%s%s\n", "Good ", $0}' sample.txt
|
|
#4
|
||||
|
||||
|
Another way to t do the work :
Code:
sed 's/^/Good /' sample.txt |
|
#5
|
|||
|
|||
|
Thanks for replay ...
pls let me know . Whether we can do in VI Editor or not .. |
|
#6
|
||||
|
||||
|
in vi editor
Code:
:%s/^/Good/g |
|
#7
|
||||
|
||||
|
also in vi(m) type
g g C+v M+g M+i, type 'Good ', then Esc |
||||
| Google The UNIX and Linux Forums |