Shell Scripting -- sed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell Scripting -- sed
# 1  
Old 03-08-2011
Shell Scripting -- sed

Hi,

In one of my scripts, I am using sed to do an expression replacement. The code in the script is as under

sed "s|MY_INP_Lab=""|MY_INP_Lab="${2}"|" file1, where $2=xyz_abc_mbk

The EXPECTED output is in file1, all the instances ofMY_INP_Lab="" shall be replaced by MY_INP_Lab="xyz_abc_mbk"

But the ACTUAL output is

MY_INP_Lab=xyz_abc_mbk""

Can someone please help in telling me why I am not getting the required output. And how can I get the expected output.

Thanks,
Vivek.
# 2  
Old 03-08-2011
Try like this,
Code:
sed 's|MY_INP_Lab=""|MY_INP_Lab="'$2'"|' testfile1

This User Gave Thanks to pravin27 For This Post:
# 3  
Old 03-09-2011
Thanks

Hi Pravin,

I tried it and it works, Thanks.


Regards,
Vivek.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help shell scripting using awk or sed or other

I need to create a script to change a file depending of 3 conditions using a target as parameter... first condition <chamada> <numeroTerminalOriginador>CALLER</numeroTerminalOriginador> <imeiOriginador></imeiOriginador> <cgiPrimeiraErbOriginador></cgiPrimeiraErbOriginador>... (2 Replies)
Discussion started by: poulis
2 Replies

2. Shell Programming and Scripting

Use case insensitive variable in ksh shell scripting using sed or awk

I am using a variable called $variable in a pattern search to print from a starting variable to a constant value. the variable search should be case in sensitive. i tired using Ip at the end in the below command. but in ksh it is not working. sed -n "/$variable/,/constant/p" file i also... (11 Replies)
Discussion started by: johnjs
11 Replies

3. Shell Programming and Scripting

Scripting awk or sed or shell

input buff_1 abc satya_1 pvr_1 buff_2 def satya_1 pvr_1 buff_3 ghi satya_1 pvr_1 buff_4 jkl satya_1 pvr_1 required out put buff_1 abc satya_1 pvr_1 abc satya_1 buff_2 def satya_1 pvr_1 def satya_1 buff_3 ghi satya_1 pvr_1 ghi satya_1 (6 Replies)
Discussion started by: pvr_satya
6 Replies

4. What is on Your Mind?

Shell scripting vs Perl scripting

Hi all, I would like to start developping some good scripting skills. Do you think it would be best to start with shell scripting or Perl? I already got a fundation, really basics, in perl. but I am wondering what would be best to be good at first. Can you please help me determine which one to... (14 Replies)
Discussion started by: Pouchie1
14 Replies

5. Shell Programming and Scripting

Call Shell scripting from Perl Scripting.

Hi How to call a shell scripting through a Perl scripting? Actually I need some value from Shell scripting and passes in the Perl scripting. So how can i do this? (2 Replies)
Discussion started by: anupdas
2 Replies

6. Shell Programming and Scripting

sed/shell scripting - add line if needed and not allready there

I am writing a shell script that checks all .c files to see if they use fprintf or printf. If a file does, then the line #include <stdio.h> is added to the top of the file, unless it's already there. This is what I've got: #!/bin/sh egrep -l f?printf *.c | while read file; do sed -i '1i\... (2 Replies)
Discussion started by: computethis
2 Replies

7. Shell Programming and Scripting

Sed function is shell scripting

Hello everybody, I trying to convert a text inside my file that looks something like this: into hyperlink so that the user can click onto it..... I tried this but doesn't work cat mylist9.html |sed -e '<a href="' >mylist13.html Thanks (13 Replies)
Discussion started by: kev_1234
13 Replies

8. Shell Programming and Scripting

usage...sed/awk/reg-exp ..in shell scripting

in shell scripting there is extensive usage of i> regular expression ii>sed iii>awk can anyone tell me the suitable contexts ...i mean which one is suitable for what kind of operation. like the reg-exp and sed seems to be doing the same job..i.e pattern matching (1 Reply)
Discussion started by: mobydick
1 Replies

9. Shell Programming and Scripting

difference between AIX shell scripting and Unix shell scripting.

please give the difference between AIX shell scripting and Unix shell scripting. (2 Replies)
Discussion started by: haroonec
2 Replies

10. Shell Programming and Scripting

Help on SED AWK in shell scripting

Hi, I have a script abc.sql which contains a word 'timestamp'. I have another script xyz.txt genrated everyweek, which has a new timestamp value every week. How do I replace the word 'timestamp' in script abc.sql with the value mentioned in the script xyz.txt, so that I can run the script... (3 Replies)
Discussion started by: kaushys
3 Replies
Login or Register to Ask a Question