![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 |
| Replacing a string in nth line | maxmave | Shell Programming and Scripting | 1 | 06-04-2008 05:32 PM |
| replacing string in an XML file | subin_bala | Shell Programming and Scripting | 2 | 06-03-2008 07:14 AM |
| using tab to finish command line parameter | kymberm | Shell Programming and Scripting | 3 | 09-20-2002 03:54 PM |
| Command line parameter for C program | Wing m. Cheng | High Level Programming | 3 | 05-18-2002 09:43 AM |
| Command Line width parameter | Scoogie | UNIX for Dummies Questions & Answers | 2 | 02-08-2002 05:04 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
replacing a string in a file with command line parameter
Hello,
I am trying to replace a string with a paramter given along with the script. I am replacing application1 to application2 with the script: ./change_app.sh application2 change_app.sh: #!/bin/ksh grep $1 applications.dat 2>&1 >/dev/null echo $1 file=pckage.new sed 's/Name: application1/Name: ${1}/g' "$file" > ./tmpfile mv ./tmpfile "$file" applications.dat has all the applications But I get output as ${1} instead of application2. But when I echo $1, I get application2. Please help in where I am going wrong, or if there is any better way. Thanks |
|
||||
|
Oops.. Thank you.
Quick question: What do I have to do if I don't know the application1 name, but have to change - say a string next to Name: with application2. sed 's/Name: application1/Name: '${1}'/g' "$file" > ./tmpfile How do I refer application1 globally ? |
|
||||
|
I have a Version Name: 1.0.0_A0
I have to change to 1.1.0_A1 With the script sed -e "s/Name: [[:alnum:]]\{1,\}/Name: ${1}/g" "$file" > ./tmpfile The output I am getting is 1.1.0_A10.0_A0 I think its stopping when it sees '.' Can you please tell me what do I need to do for special characters ?? Thanks |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|