search the pattern in a file and replace with variable already defined previously in csh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting search the pattern in a file and replace with variable already defined previously in csh
# 1  
Old 04-13-2010
search the pattern in a file and replace with variable already defined previously in csh

I want to replace a certain pattern with the variable already defined.
e.g.
Code:
set path_verilog = /home/priya/bin/verilogfile

my file contents are :
Code:
verilog new
verilog is defined here verilog_path_comes

I am using the below command
Code:
sed 's/verilog_path_comes/'$path_verilog'/g' <filename>

but its not working. Probably the reason is variable contains special character '/' due to which it cannot replace the value

Last edited by Franklin52; 04-13-2010 at 07:25 AM.. Reason: Please use code tags!
# 2  
Old 04-13-2010
Here you are:

Code:
sed 's|verilog_path_comes|'$path_verilog'|g'

Regards,
-Artur.

Last edited by Franklin52; 04-13-2010 at 07:25 AM.. Reason: Please use code tags!
# 3  
Old 04-13-2010
Its working perfectly. Thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to delete all lines before a particular pattern when the pattern is defined in a variable?

I have a file Line 1 a Line 22 Line 33 Line 1 b Line 22 Line 1 c Line 4 Line 5 I want to delete all lines before last occurrence of a line which contains something which is defined in a variable. Say a variable var contains 'Line 1', then I need the following in the output. ... (21 Replies)
Discussion started by: Soham
21 Replies

2. Post Here to Contact Site Administrators and Moderators

Search for a pattern and replace a space at specific position with a Character in File

In file, we have millions of records each of 1000 in length. And at specific position say 800 there is a space, we need to replace it with Character X if the ID in that row starts with 123. So far i have used the below which is replacing space at that position to X but its not checking for... (3 Replies)
Discussion started by: Jagmeet Singh
3 Replies

3. Shell Programming and Scripting

awk variable search and line count between variable-search pattern

Input: |Running the Rsync|Sun Oct 16 22:48:01 BST 2016 |End of the Rsync|Sun Oct 16 22:49:54 BST 2016 |Running the Rsync|Sun Oct 16 22:54:01 BST 2016 |End of the Rsync|Sun Oct 16 22:55:45 BST 2016 |Running the Rsync|Sun Oct 16 23:00:02 BST 2016 |End of the Rsync|Sun Oct 16 23:01:44 BST 2016... (4 Replies)
Discussion started by: busyboy
4 Replies

4. Shell Programming and Scripting

Mutli line pattern search & replace in a xml file

Hello guys, I need your help for a specific sed command that would search for a multi line pattern and if found, would replace it by another multi line pattern. For instance, here is the input: <RefNickName>abcd</RefNickName> <NickName>efgh</NickName> <Customize> ... (0 Replies)
Discussion started by: xciteddd
0 Replies

5. UNIX for Dummies Questions & Answers

search a pattern across all file and replace it to all files.

Hi All, HP-UX oradev3 B.11.11 U 9000/800 I have few files, which contain texts. Now I need to search a pattern across all files and replace to that pattern with new one. For example, I have following files they have, which contain something like abc@abc.com, now I need to search text acorss... (6 Replies)
Discussion started by: alok.behria
6 Replies

6. Shell Programming and Scripting

Help needed :Search and Replace a string pattern with empty in an xml file in unix

Search and Replace a string pattern with empty in an xml file in unix: My xml file would be like this : <Accounts><Name>Harish</Name><mobile>90844444444444445999 </mobile><TRIG>srcujim-1</TRIG></Accounts><Accounts><Name>Satish</Name><mobile>908999</mobile><TRIG>ettertrtt-1</TRIG></Accounts> ... (1 Reply)
Discussion started by: harish_s_ampeo
1 Replies

7. AIX

External Snapshot using previously defined lv

I prefer to assign my own lv names rather than the automatic LV creation that the snapshot Can it be done or is IBM's man page flawed? I am on AIX 6.1 TL 04 Machine type 9133-55A All local SCSI storage. I manually create the lv and attempt to create the snapshot: # mklv -y snapfs99... (2 Replies)
Discussion started by: Skyybugg
2 Replies

8. UNIX for Dummies Questions & Answers

Perl search and replace not working in csh script

I am using perl to perform a search and replace. It works at the command line, but not in the csh shell script perl -pi -e 's@/Pattern@@g' $path/$file I used the @ as my delimiter because the pattern contains "/" (3 Replies)
Discussion started by: NobluesFDT
3 Replies

9. Shell Programming and Scripting

Replace variable with a user defined variable

I have a file that has a list of entries in a column x z z z x y z The column can have any length and any number of any strings. I need to replace each unique string with a user defined number. I can filter the unique entries out using awk '{if (NF==5) print $2}' file | uniq | nl >... (1 Reply)
Discussion started by: ce124
1 Replies
Login or Register to Ask a Question