Sponsored Content
Top Forums Shell Programming and Scripting Function to add escape character before specified character Post 302881507 by kurumi on Monday 30th of December 2013 03:00:59 AM
Old 12-30-2013
Code:
# echo "abcd fkaj&dsdsd" | ruby -e 's=gets; puts s.gsub(/([& ;])\1*/,"\\\\\\1")'
abcd\ fkaj\&dsdsd

This User Gave Thanks to kurumi For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

possible to escape the \ character in sed?

is it possible to escape the \ character in sed? right now I'm trying to replace all occurances of \ with \\ sed \"s|test|test_replacement|g\" file1 > output; #this works fine sed \"s|\\|\\\|g\" file1 > output; #this generates the following error: sed: -e expression #1, char 17:... (1 Reply)
Discussion started by: gammaman
1 Replies

2. Shell Programming and Scripting

Escape character in vi?

I want to replace a string which contains "/" in vi but what is the escape character for forward slash? e.g. I have a text file with the contents below and I want to replace "/Top/Sub/Sub1" with "ABC". /Top/Sub/Sub1 The replace command I am using is ... (4 Replies)
Discussion started by: stevefox
4 Replies

3. Shell Programming and Scripting

awk / escape character

Hi I'm trying to split a dir listing eg /home/foo1/foo2 I'm using ksh I've tried dir=/home/foo1/foo2 splitit=`echo $dir | awk -F '\/' '{print $1}'` echo $splitit nothing is output! I have checked the escape character. The only one I have found is \ BTW `pwd` | awk -F \/... (8 Replies)
Discussion started by: OFFSIHR
8 Replies

4. Shell Programming and Scripting

Escape character

Hi , I want to change space to ' in my script. I tried doing this, sed 's/ /\'/g' filename but i could not get it. can some one help me please. Thanks, Deepak (4 Replies)
Discussion started by: deepakpv
4 Replies

5. Shell Programming and Scripting

escape character in tcsh

Hello, I wanted to display command with echo like this in tcsh. output should be "//'test.test1.test2'" (" at both ends also required in output) Please help me. (1 Reply)
Discussion started by: balareddy
1 Replies

6. Shell Programming and Scripting

Escape character in sed

Hello experts I am trying to write a shell script which will add ' ' to a unix variable and then pass it to oracle for inserting to a table. I am running the script as root and I have to do a su -c . The problem is the character ' is not recognised inside sed even after adding escape... (1 Reply)
Discussion started by: pvedaa
1 Replies

7. UNIX for Advanced & Expert Users

if 4th and 5th character of sting -ge 45 then add 1 to 3rd character

I want to know how to, given a string like W87151WR71C, if the 4th and 5th character (in this case 15) are greater than 45, then to add 1 to the 3rd character (in this case 7) and assign the revised string the variable name MODSTRING. Thanks in advance. This is ultimately to grab info from... (6 Replies)
Discussion started by: glev2005
6 Replies

8. Shell Programming and Scripting

Problem with using a sed to add escape character \ before $ and ' symbols

Hi all, I've got a problem with sed. Want to use it to add escape character \ before $ and ' symbols so condition='1'$some will become condition=\'1\'\$some echo "condition='1'$some" | sed 's/\($\)/\\\1/g' is not working properly. Can somebody help me with this please? Regards,... (7 Replies)
Discussion started by: johny_be_good
7 Replies

9. Shell Programming and Scripting

sed - with escape character

i have string as below str=".<date>" in which i need to replace < with /< , when i tried with sed , got the output. --> echo $str | sed 's/</\\</g' .\<date> when i tried to assign it to a variable , i am not getting the same --> a=`echo $str | sed 's/</\\</g'` ; echo $a... (4 Replies)
Discussion started by: expert
4 Replies

10. Shell Programming and Scripting

Escape special character

Hi, How to use * in call to pl/sql block from shell script? The line "select * from" is causing all files and directiores to show up in email notification but if I give all column names then it works, Please let me know how to use '*' instead of giving all column names, in other wirds how to... (2 Replies)
Discussion started by: sandy162
2 Replies
libcaca-ruby-api(3caca) 					      libcaca						   libcaca-ruby-api(3caca)

NAME
libcaca-ruby-api - Libcaca Ruby API Classes The classes available for libcaca are : o Caca::Canvas : functions that have a caca_canvas_t* as first argument o Caca::Dither : functions that have a caca_dither_t* as first argument o Caca::Font : functions that have a caca_font_t* as first argument (The constructor can currently only accept the name of a builtin font) o Caca::Display o Caca::Event o Caca::Event::Key o Caca::Event::Key::Press o Caca::Event::Key::Release o Caca::Event::Mouse o Caca::Event::Mouse::Press o Caca::Event::Mouse::Release o Caca::Event::Mouse::Motion o Caca::Event::Resize o Caca::Event::Quit The character set conversion functions are not available yet in the binding. $ irb -rcaca irb(main):001:0> class Object irb(main):002:1> def Object.my_instance_methods irb(main):003:2> instance_methods.sort - ancestors[1].instance_methods irb(main):004:2> end irb(main):005:1> def Object.my_methods irb(main):006:2> methods.sort - ancestors[1].methods irb(main):007:2> end irb(main):008:1> end irb(main):009:0> Caca.constants => ['BROWN', 'BOLD', 'GREEN', 'LIGHTMAGENTA', 'LIGHTBLUE', 'BLINK', irb(main):010:0> Caca.my_methods => ['version'] irb(main):011:0> Caca::Canvas.my_methods => ['export_list', 'import_list'] irb(main):012:0> Caca::Canvas.my_instance_methods => ['attr=', 'blit', 'clear', 'create_frame', irb(main):013:0> Caca::Font.my_methods => ['list'] irb(main):014:0> Caca::Font.my_instance_methods => ['blocks', 'height', 'width'] irb(main):015:0> Caca::Dither.my_instance_methods => ['algorithm=', 'algorithm_list', 'antialias=', 'antialias_list', irb(main):010:0> Caca::Display.my_instance_methods => ['canvas', 'get_event', 'height', 'mouse=', 'mouse_x', 'mouse_y', 'refresh', irb(main):011:0> Caca::Event.constants => ['Key', 'Quit', 'TYPE', 'Mouse', 'Resize'] irb(main):012:0> Caca::Event.my_instance_methods => ['quit?'] irb(main):013:0> Caca::Event::Key.my_instance_methods => ['ch', 'utf32', 'utf8'] irb(main):014:0> Caca::Event::Mouse.my_instance_methods => ['button', 'x', 'y'] irb(main):015:0> Caca::Event::Resize.my_instance_methods => ['w', 'h'] Samples $ ruby -rcaca -e 'c=Caca::Canvas.new(6, 3).fill_box(0,0,2,2,'#'[0]); c2=Caca::Canvas.new(1,1).put_str(0,0,'x'); c.blit(1,1,c2); puts c.export_to_memory('irc')' ### #x# ### $ ruby -e 'puts Caca::Canvas.new(6,3).draw_thin_polyline([[0,0], [0,2], [5,2],[0,0]]).export_to_memory('irc')' -. | `. ----`- $ ruby -rcaca -e 'p Caca::Canvas.export_list' [['caca', 'native libcaca format'], ['ansi', 'ANSI'], ['utf8', 'UTF-8 withANSI escape codes'], ['utf8cr', 'UTF-8 with ANSI escape codes and MS-DOS '], ['html', 'HTML'], ['html3', 'backwards-compatible HTML'], ['irc', 'IRC with mIRC colours'], ['ps', 'PostScript document'], ['svg', $ ruby -rcaca -e 'p Caca::Font.list' ['Monospace9', 'Monospace Bold 12'] require 'caca' c = Caca::Canvas.new(20,10) c.put_str(2,3, 'plop!') c.draw_thin_polyline([[0,0],[0,2], [5,2], [0,0]]) d = Caca::Display.new(c) d.title= 'Test !' d.refresh #Redefine Event::Key#quit? so that q, Q, and Esc become exit keys module Caca class Event::Key def quit? 'qQ^['.split('').member?(@ch.chr) end end end while((e= d.get_event(Caca::Event, -1)) && ! e.quit?) p e d.refresh end Version 0.99.beta18 Fri Apr 6 2012 libcaca-ruby-api(3caca)
All times are GMT -4. The time now is 03:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy