Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Replace line with found unknown pattern Post 302460539 by kurumi on Thursday 7th of October 2010 03:53:44 AM
Old 10-07-2010
Code:
$ ruby -ne '$_=$_.scan(/(tc_\d+)/)[0] if $_["tc_"];puts $_' file

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

change line found by pattern using sed

I want to change a line like CPM_THRESHOLD 0.8 // to a new value using sed I am trying sed -i "s/CPM_THRESHOLD/CPM_THRESHOLD\t$COH\t\t\/\//" $INPUT_4 but how can i substitute the whole line begining with CPM_THRESHOLD and substitute it? (2 Replies)
Discussion started by: larne
2 Replies

2. Shell Programming and Scripting

How to replace a line below where the pattern found

Hi All, I have a file say abc.xml. In this file, I need to search for a pattern “SAP_GATEWAY_HOST”; if this pattern found and the next line also contain the pattern “nwprc03.cos” then I need to replace this pattern “nwprc03.cos” with some other pattern “nwdrc03.apjp”. $ cat abc.xml... (3 Replies)
Discussion started by: Ritesh.patni84
3 Replies

3. Shell Programming and Scripting

Delete line if pattern not found

I thought that this was going to be quit simple using sed but i wasn't able to find a way to delete the second line of a text file if my pattern was not found in the line With awk i am completly useless :rolleyes: Any ideas? (2 Replies)
Discussion started by: jepeto
2 Replies

4. Shell Programming and Scripting

To find the line no, where the particular pattern is not found

Hi, suppose i have a txt file containing thye following data 2012156|sb3|nwknjps|BAYONNE|NJ|tcg 201221|094|mtnnjprc:HACKENSACK|NJ|tcg 201222|wn3|mtnnjtc|HACKENSACK|NJ|tcg 2018164|ik4|mtnntc|JERSEY CITY|NJ|tcg 20123482|ik4|mtnnjpritc,JERSEY CITY|NJ|tcg... (3 Replies)
Discussion started by: priyanka3006
3 Replies

5. Shell Programming and Scripting

extract specific line if the search pattern is found

Hi, I need to extract <APPNUMBER> tag alone, if the <college> haas IIT Chennai value. college tag value will have spaces embedded. Those spaces should not be suppresses. My Source file <Record><sno>1</sno><empid>E0001</empid><name>Rejsh suderam</name><college>IIT ... (3 Replies)
Discussion started by: Sekar1
3 Replies

6. Shell Programming and Scripting

Append next line to previous line when one pattern not found

Hi, I need help for below scenario.I have a flat file which is having records seperated by delimiters which will represent each record for oracle table.My Control file will consider each line as one record for that table. Some of the lines are aligned in two/three lines so that records are... (4 Replies)
Discussion started by: kannansr621
4 Replies

7. Shell Programming and Scripting

pattern match and replace another pattern in same line

I have a pattern username:x:32005:32006::/usr/local/user:/bin/bash I need to match the line containing username and replace /bin/bash with /usr/local/my/bin/noshell So it becomes username:x:32005:32006::/usr/local/user:/usr/local/my/bin/noshell (7 Replies)
Discussion started by: anilcliff
7 Replies

8. Shell Programming and Scripting

Read file and replace a particular line if found

Hi All There is another challenge which stand in front of me. And want all to have the experience with that I have a file in Unix say a.txt. What I was trying is to read the file line by line and matching the line to particular pattern, and if that pattern found I want to replace that line... (5 Replies)
Discussion started by: adisky123
5 Replies

9. Shell Programming and Scripting

If first pattern is found, look for second pattern. If second pattern not found, delete line

I had a spot of trouble coming up with a title, hopefully you'll understand once you read my problem... :) I have the output of an ldapsearch that looks like this: dn: cn=sam,ou=company,o=com uidNumber: 7174 gidNumber: 49563 homeDirectory: /home/sam loginshell: /bin/bash uid: sam... (2 Replies)
Discussion started by: samgoober
2 Replies

10. Shell Programming and Scripting

Append text on particular line after pattern found

hi, i have /etc/inittab, I want to add another line after that when i find a pattern "l6:6:wait:/etc/rc.d/rc 6". original l6:6:wait:/etc/rc.d/rc 6 after-change l6:6:wait:/etc/rc.d/rc 6 /sbin/if-pp-to-cng (3 Replies)
Discussion started by: learnbash
3 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 07:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy