![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need Replacement for sed | dbsurf | Shell Programming and Scripting | 0 | 01-25-2008 06:47 PM |
| Awk variable replacement | iAm4Free | Shell Programming and Scripting | 5 | 08-30-2007 12:14 PM |
| Regarding Replacement | rajx | UNIX for Dummies Questions & Answers | 2 | 05-22-2007 10:19 AM |
| Replacement using sed | handak9 | UNIX for Dummies Questions & Answers | 5 | 07-13-2004 12:28 PM |
| cpu replacement. help | IMPTRUE | UNIX for Dummies Questions & Answers | 3 | 07-25-2003 09:40 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
...
input="x" while [ -z "$input" ] ; do input="" read input if [ -n "$input" ] ; then sed '/\$HOME=/ {; s/=.*$/='"$input"'/; q; }' file > file.new fi done ... just enter an empty string to leave the loop. bakunin |
|
|||||
|
things didnt work as i wanted
i have done the following the script will prompt for the new path and then read it after that he will search the file and replace this variable .... this is a kind of cotumization . input="/home while [ -z "$input" ] ; do input="" echo "please enter the location:\c" read input if [ -n "$input" ] ; then sed '/\$HOME=/ {; s/=.*$/='"$input"'/; q; }' /file > /file.new fi done NOTE : iam using ksh , Solaris 9 over sparc Last edited by ppass; 06-01-2005 at 08:11 AM.. |
|
||||
|
sorry, I tripped over my own (sed-)foot. ;-))
The sed-script will terminate after the first occurrence of "home=..." and hence the lines following will be lost from the output file. replace the then ... fi -part with the following: iFirst=$( print - 'g/^[<blank><tab>]*\'$input'/n' |\ ed - file |\ sed '1 s/<tab>.*$//; 2,$d' \ ) sed $iFirst' s/=.*$/='"$input"'/' file > file.new iFirst is a variable holding the first occurrence of your search string. You will have to replace <blank> and <tab> by real tabs and blanks. bakunin |
|
|||||
|
sorry, not working
input="/home while [ -z "$input" ] ; do input="" echo "please enter the location:\c" read input if [ -n "$input" ] ; then iFirst=$( print - 'g/^[<blank><tab>]*\'$input'/n' |\ ed - file |\ sed '1 s/<tab>.*$//; 2,$d' \ ) sed $iFirst' s/=.*$/='"$input"'/' file > file.new fi done i have treid to modify it ut with little luck ... thanks for ur help |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|