How to add \ in front of $ in a script with vi?


 
Thread Tools Search this Thread
Operating Systems Linux How to add \ in front of $ in a script with vi?
# 1  
Old 01-27-2015
How to add \ in front of $ in a script with vi?

Please help to provide command in vi to add \ in front of $ so it does not interpret next character.

Code:
rm interfaces/DART/WEB-INF/classes/DART/util/TotalDisconnectUtil$1.class
rm interfaces/DART/WEB-INF/classes/DART/util/TotalDisconnectUtil$2.class
rm interfaces/RRIF/WEB-INF/classes/RRIF/util/Circuit$Sect.class

i would like to add \ in front of $ like below in vi

Code:
rm interfaces/DART/WEB-INF/classes/DART/util/TotalDisconnectUtil\$1.class
rm interfaces/DART/WEB-INF/classes/DART/util/TotalDisconnectUtil\$2.class
rm interfaces/RRIF/WEB-INF/classes/RRIF/util/Circuit\$Sect.class


Last edited by Scrutinizer; 01-27-2015 at 01:47 PM.. Reason: code tags
# 2  
Old 01-27-2015
Hi,
this should do the trick:
Code:
:1,$s/\$/\\\$/g

# 3  
Old 01-27-2015
Please use code tags as required by forum rules!

Where (and why) do you need those escaped $s? What do you want to achieve? There might be easier/better suited ways to get at it if we knew the entire picture.
For just your question, try
Code:
sed 's/\$/\\\$/' file
rm interfaces/DART/WEB-INF/classes/DART/util/TotalDisconnectUtil\$1.class
rm interfaces/DART/WEB-INF/classes/DART/util/TotalDisconnectUtil\$2.class
rm interfaces/RRIF/WEB-INF/classes/RRIF/util/Circuit\$Sect.class

# 4  
Old 01-27-2015
Cero, thank you so much for quick response, Yes. it worked.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to add space in front of cat values?

Hi, Hope you are all doing fine. The problem today i faced during my coding was i wanted to add a space equals to a tab character in front of all the lines which i am cat using tee command. Main file contents mainfile ... (4 Replies)
Discussion started by: mad man
4 Replies

2. Shell Programming and Scripting

Add text in front of variable

I am just trying to add specific text in front of a ${variant} but can not seem to get the syntax correct. I have tried sed -i '$a NM_004004.5' ${variant} and printf "NM_004004.5:%s\n" ${variant} with no luck. Thank you :). (7 Replies)
Discussion started by: cmccabe
7 Replies

3. Shell Programming and Scripting

Script for adding a word in front of all line in a file

Hi I've one file full of paths of certain files and I want to add some extra file words in front of all the paths. for eg: i have a file name test.txt which show some details only.. 024_hd/044/0344eng.txt 035_bv/222/editor.jpg here I want to add /usr/people/indiana/ infront of all the... (4 Replies)
Discussion started by: ratheeshp
4 Replies

4. Shell Programming and Scripting

how to add single digit in front of the word and line in the file.

Hi , how to add the single digit to front of the word and front of the lines in the one file with compare pattern file and get digit. like example pattern file pattern.txt pattern num bala 2 raja 3 muthu 4 File Name: chennai.dat muthu is good boy raja is bad boy selvam in super... (6 Replies)
Discussion started by: krbala1985
6 Replies

5. Shell Programming and Scripting

What is the difference executing a script with . in the front versus not putting a "."

Hi All, I know this has been discussed a lot but still I need some more answers. I am running this is ksh on AIX 5.3 I believe putting a "." in front of the script will start a new shell, is that correct?? I have a script which override some PATH variables and it does not do that... (3 Replies)
Discussion started by: Hangman2
3 Replies

6. Shell Programming and Scripting

How join line and add | in front

Hello, Did any one know how to use perl join line and add | in front Input--> timestamp=2009-11-10-04.55.20.829347; a; b; c; ddaa; timestamp=2009-11-10-04.55.20.829347; aa; bb; cc; Output--> ... (2 Replies)
Discussion started by: happyday
2 Replies

7. Shell Programming and Scripting

Want to add a word in front a of each line of a file

Hi, Can anybody help me how to add a word in front of a line in a file.Actually it is bit tricky to add a word. i will give a sample for this: Input : 1110001 ABC DEF 1110001 EFG HIJ 1110001 KLM NOP 1110002 QRS RST 1110002 UVW XYZ Output: %HD% 1110001 ABC DEF %DT% 1110001 EFG HIJ... (4 Replies)
Discussion started by: apjneeraj
4 Replies

8. Shell Programming and Scripting

How cgi(shell script) to receive the URL REQUEST from Front end (visual C++)?

I am facing a problem which is weblogic convert to CGI method. The original process is -> the Front End is using Visual C++, and backend is using WEBLOGIC the based programming is JAVA. The method for Weblogic to receive the request from Front end (Visual C++) thru URL. for example :... (0 Replies)
Discussion started by: ryanW
0 Replies

9. Shell Programming and Scripting

bash - add backslash in front of variables w/ spaces

Hello, Im writing a script that works by recursively going into directories with find. But I have some directories that have spaces in them.. so I need to parse the variables to add a backslash before the spaces. Im not exactly sure how how to do this in bash, and honestly I dont think I know... (3 Replies)
Discussion started by: trey85stang
3 Replies

10. Shell Programming and Scripting

run script with ./ in front of name

on unix AIX5.3, we run a scripts by entering the script name on the command line and sometimes we get a not found error and then we put ./ in front on the name and it runs. Why? :confused: (3 Replies)
Discussion started by: rig123
3 Replies
Login or Register to Ask a Question