Pattern Matching and text deletion using VI


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Pattern Matching and text deletion using VI
# 1  
Old 10-28-2011
Pattern Matching and text deletion using VI

Can someone please assist me, I'm trying to get vi to remove all the occurences of the text in a file i.e. "DEVICE=/dev/mt??". The "??" represents a number variable. Is there a globel search and delete command that I can use?
Thank You in Advance.
# 2  
Old 10-28-2011
Code:
# to delete
:%s#DEVICE=/dev/mt[0-9][0-9]##g

# 3  
Old 10-28-2011
I'm using AIX, if that makes a difference. Is the # correct? My docs show "/" instead.
# 4  
Old 10-28-2011
Quote:
Originally Posted by roadrunner
I'm using AIX, if that makes a difference. Is the # correct? My docs show "/" instead.
it can be any single character. If you use '/' you'll need to escape the '/' in the path of your device with '\'.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk to add text to matching pattern in field

In the awk I am trying to add :p.=? to the end of each $9 that matches the pattern NM_. The below executes andis close but I can not seem to figure out why the :p.=? repeats in the split as in the green in the current output. I have added comments as well. Thank you :). file ... (4 Replies)
Discussion started by: cmccabe
4 Replies

2. Shell Programming and Scripting

Sed: printing lines AFTER pattern matching EXCLUDING the line containing the pattern

'Hi I'm using the following code to extract the lines(and redirect them to a txt file) after the pattern match. But the output is inclusive of the line with pattern match. Which option is to be used to exclude the line containing the pattern? sed -n '/Conn.*User/,$p' > consumers.txt (11 Replies)
Discussion started by: essem
11 Replies

3. Shell Programming and Scripting

Find all matching words in text according to pattern

Hello dear Unix shell professionals, I am desperately trying to get a seemingly simple logic to work. I need to extract words from a text line and save them in an array. The text can look anything like that: aaaaaaa${important}xxxxxxxx${important2}ooooooo${importantstring3}...I am handicapped... (5 Replies)
Discussion started by: Grünspanix
5 Replies

4. UNIX for Dummies Questions & Answers

sed - combination of line deletion and pattern matching

I want to delete all the blank lines from a file before a certain line number. e.g. Input file (n: denotes line number) 1: a 2: 3: b 4: c 5: 6: d I want to delete all blank lines before line number 3, such that my output is: a b c d I see that sed '/^$/d' in_file works... (9 Replies)
Discussion started by: jawsnnn
9 Replies

5. UNIX Desktop Questions & Answers

Trying to delete a directory pattern-selective deletion

Trying to delete a directory or a file using a pattern-selective deletion (using “*” and “?” ) (4 Replies)
Discussion started by: herberwz
4 Replies

6. Shell Programming and Scripting

insert text into another file after matching pattern

i am not sure what i should be using but would like a simple command that is able to insert a certain block of text that i define or from another text file into a xml file after a certain match is done for e.g insert the text </servlet-mapping> <!-- beechac added - for epic post-->... (3 Replies)
Discussion started by: cookie23patel
3 Replies

7. UNIX for Advanced & Expert Users

pattern matching with comma delimited text

Hi, I have two files that I need to match patterns with and the second file has comma delimited rows of data that match but I'm having trouble getting a script to work that gives me the match output to these sets : file 1: PADG_05255 PADG_06803 PADG_07148 PADG_02849 PADG_02886... (8 Replies)
Discussion started by: greptastic
8 Replies

8. Shell Programming and Scripting

comment/delete a particular pattern starting from second line of the matching pattern

Hi, I have file 1.txt with following entries as shown: 0152364|134444|10.20.30.40|015236433 0233654|122555|10.20.30.50|023365433 ** ** ** In file 2.txt I have the following entries as shown: 0152364|134444|10.20.30.40|015236433 0233654|122555|10.20.30.50|023365433... (4 Replies)
Discussion started by: imas
4 Replies

9. Shell Programming and Scripting

text manipulation and pattern matching

Hi guys, I need help: I started receiving automatic emails containing download information. The problem is that these emails are coming in a rich format (I have no control of this) so the important information is buried under a bunch of mumbo-jumbo. To complicated things even further I need to... (10 Replies)
Discussion started by: caprica13
10 Replies

10. UNIX for Dummies Questions & Answers

vi part-pattern matching and deletion

Hi, I have a log file which shows the files which has been changed over the last week. They follow this pattern: old_file_version_number@@new_file_version_number Now I need to know how to delete from each line parts starting from @@. I would be issuing the command inside vi(m). So... (5 Replies)
Discussion started by: vino
5 Replies
Login or Register to Ask a Question