How do mask off the string that match my value?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How do mask off the string that match my value?
# 1  
Old 03-12-2011
How do mask off the string that match my value?

Hi,

I have a file like following,

Code:
aaabb
aaavv
bbdddaaab
fgdgjhaa
bfd
12352aa
dgs1xaf
sdgsdyg4

How can i get the output below(mask off all the line that have "a") by using vim
Code:
#aaabb
#aaavv
#bbdddaaab
#fgdgjhaa
bfd
#12352aa
#dgs1xaf
sdgsdyg4

thanks & best regards
Moderator's Comments:
Mod Comment
Please use code tags when posting data and code samples!

Last edited by vgersh99; 03-13-2011 at 07:44 PM.. Reason: code tags, please!
# 2  
Old 03-13-2011
Code:
:%s/^.*a.*$/#&/

maybe even
Code:
:/a/s/.*/#&/

---------- Post updated at 11:26 PM ---------- Previous update was at 11:20 PM ----------

oops the second fails (i forgot to address all lines)
keep with
Code:
:%s/.*a.*/#&/

this should work

Last edited by Scott; 03-13-2011 at 08:55 PM..
# 3  
Old 03-14-2011
ya, is work... thank you very much...
by the way, what is the meaning to putting a "&" behind the #??
# 4  
Old 03-14-2011
& refer to what has been matched by what is within the first / .... / (in our case, any string containing an "a")
# 5  
Old 03-14-2011
thanks, i love this forum very much... gained a lot
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep match a mask

Hi all, Im trying to use grep to match a exact mask where some characters are known and some are not. for example: j***n@email.com in this case the length is known and the position of the unknown characters are know (and will be ) any idea how I can do this? the file list is not just... (3 Replies)
Discussion started by: flamer
3 Replies

2. Shell Programming and Scripting

Match exactly a string

I am formatting my code and for that I am trying to write a script which can quicken some repetitive work. I need to match "==" exactly in a string and replace it by inserting a (single) blank space before and after it. Sample Strings: 1.this.something =='something'.that... (9 Replies)
Discussion started by: prohank
9 Replies

3. Shell Programming and Scripting

awk : match the string and string with the quotes :

Hi all, Here is the data file: - want to match only lan3 in the output . - not lan3:1 file : OPERATING_SYSTEM=HP-UX LOOPBACK_ADDRESS=127.0.0.1 INTERFACE_NAME="lan3" IP_ADDRESS="10.53.52.241" SUBNET_MASK="255.255.255.192" BROADCAST_ADDRESS="" INTERFACE_STATE=""... (2 Replies)
Discussion started by: rveri
2 Replies

4. UNIX for Dummies Questions & Answers

What is mask and effective right mask in setfacl?

Hi Guys, can someone explain what is mask and effective right mask in setfacl and getfacl command with example, unable to get it. (3 Replies)
Discussion started by: Jcpratap
3 Replies

5. Shell Programming and Scripting

How to print everything after a string match

Hi all, I'm trying to do some work on the authorized_keys file to do a check if there's any information after the hash key.. At the end of the hash key's in the file, there can be an = or == Is there a way to check if anything exists after these equals and if so print it out or else print... (2 Replies)
Discussion started by: Jazmania
2 Replies

6. Shell Programming and Scripting

How can I match the particular character in the string?

Hi, I want to check out a word in the text file and generate a clear report for me to see... The text file content: Content: ............ 20120608: 20120608: ............ 20120608: .......... 2012031201: , hime] End of the file My expected output is: Full TXT: manatsu TXT:... (3 Replies)
Discussion started by: meroko
3 Replies

7. Red Hat

Samba create mask and dir mask on RHEL 4.8

Hi Experts, I'm using samba -3.6.1 on Red Hat Enterprise Linux ES release 4 (Nahant Update 8) ,all seems ok. The issue im facing is as follows. When ever a user creates a file via windows explorer the permissions assgined to the file are as follows -rw-rwxr--+ 1 tom group2 0 Mar 9... (1 Reply)
Discussion started by: maverick_here
1 Replies

8. Shell Programming and Scripting

pattern match in a string

Hello, Please see below line code: #!/bin/ksh set -x /usr/bin/cat /home/temp |while read line do if ] then echo "matched" else echo "nope" fi done content of filr temp is as below (4 Replies)
Discussion started by: skhichi
4 Replies

9. Shell Programming and Scripting

exact string match ; search and print match

I am trying to match a pattern exactly in a shell script. I have tried two methods awk '/\<mpath${CURR_MP}\>/{print $1 $2}' multipath perl -ne '/\bmpath${CURR_MP}\b/ and print' /var/tmp/multipath Both these methods require that I use the escape character. I am guessing that is why... (8 Replies)
Discussion started by: bash_in_my_head
8 Replies

10. Shell Programming and Scripting

Perl: Better way to match string within a string

Hi, I'm trying to get one field out of many as follows: A string of multiple fields separated with "/" characters: "/ab=12/cd=34/12=ab/34=cd/ef=pick-this.one/gh=blah/ij=something/" I want to pick up the field "ef=pick-this.one" which has no regular pattern except it starts with "ef=xxxx"... (3 Replies)
Discussion started by: Juha
3 Replies
Login or Register to Ask a Question