vi part-pattern matching and deletion


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers vi part-pattern matching and deletion
# 1  
Old 03-29-2005
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 in the end the log file will contain just:

old_file_version_number

Thanks,
Vino
# 2  
Old 03-29-2005
Usually I would suggest you search the forums but I found that it took me over an hour to find the correct (hopefully correct) solution.

To effect the complete file:
:1,$s/@@.*$//g

I'm sure those that know this better than I do (which would be most) can correct it if this is the wrong answer. But I tested and I believe it works for what you asked for.
# 3  
Old 03-29-2005
That will work or

:%s/@@.*$//g
will do the same
# 4  
Old 03-29-2005
Quote:
Originally Posted by reborg
That will work or

:%s/@@.*$//g
will do the same
actually there's no need to the trailing 'g' as there's ONLY one '$' [end of line] in a line:

:%s/@@.*$//
# 5  
Old 03-29-2005
Quote:
Originally Posted by vgersh99
actually there's no need to the trailing 'g' as there's ONLY one '$' [end of line] in a line:

:%s/@@.*$//
Very true, force of habit.
# 6  
Old 04-04-2005
Kool...thanks to all.
That worked.

Vino
 
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 'improve' this script and also 'fix' the pattern matching part?

Hi all, Below is my script. It is currently working but I want some advice on maybe improving it and need some help on the pattern matching xx.ksh: #!/bin/ksh # # ------------------------------------------------------------------------------------------------- # #Fatal NI connect error... (3 Replies)
Discussion started by: newbie_01
3 Replies

2. Shell Programming and Scripting

Taking out part of a string by matching a pattern

Hi All, My Problem is like below. I have a file which contains just one row and contains data like PO_CREATE12457888888888889SK1234567878744551111111111SK89456321145789955455555SK8888888815788852222 i want to extract SK12345678 SK89456321 SK88888888 So basically SK and next 8... (4 Replies)
Discussion started by: Asfakul Islam
4 Replies

3. Shell Programming and Scripting

PHP - Regex for matching string containing pattern but without pattern itself

The sample file: dept1: user1,user2,user3 dept2: user4,user5,user6 dept3: user7,user8,user9 I want to match by '/^dept2.*/' but don't want to have substring 'dept2:' in output. How to compose such regex? (8 Replies)
Discussion started by: urello
8 Replies

4. 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

5. 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

6. Shell Programming and Scripting

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. (3 Replies)
Discussion started by: roadrunner
3 Replies

7. 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

8. Shell Programming and Scripting

Problem extracting just a part of a matching pattern

Hello everyone, this is my first post so please give me a hand. I apologize for my English, I'll try to be clear with my request. I need to write a script (Bash) which finds all the variables defined in the file .h of the folder and then writes the name of the files .c where these variables are... (1 Reply)
Discussion started by: paxilpaz
1 Replies

9. Shell Programming and Scripting

counting the lines matching a pattern, in between two pattern, and generate a tab

Hi all, I'm looking for some help. I have a file (very long) that is organized like below: >Cluster 0 0 283nt, >01_FRYJ6ZM12HMXZS... at +/99% 1 279nt, >01_FRYJ6ZM12HN12A... at +/99% 2 281nt, >01_FRYJ6ZM12HM4TS... at +/99% 3 283nt, >01_FRYJ6ZM12HM946... at +/99% 4 279nt,... (4 Replies)
Discussion started by: d.chauliac
4 Replies

10. 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
Login or Register to Ask a Question