find regex and remove #


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting find regex and remove #
# 1  
Old 01-26-2011
find regex and remove #

hi ,

how do i remove # from a line where i found regex..

don't need to remove all the line.. only remove comment..
# 2  
Old 01-26-2011
You mean remove from the "#" to the end of line ?
Code:
 sed -e 's/#.*$//g'

# 3  
Old 01-27-2011
You want to remove the '#' character on lines that match a certain condition?
Code:
sed -e 's/#\?\(.*<your-regex-here>\)/\1/'

# 4  
Old 01-27-2011
edit your file with VI:

Code:
 
:1,$s/#regex/regex/g

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Bash to remove find and remove specific extension

The bash below executes and does find all the .bam files in each R_2019 folder. However set -x shows that the .bam extension only gets removed from one .bam file in each folder (appears to be the last in each). Why is it not removing the extension from each (this is $SAMPLE)? Thank you :). set... (4 Replies)
Discussion started by: cmccabe
4 Replies

2. Shell Programming and Scripting

Need regex shell script to remove text from file

Hello I am trying to remove a line like <?php /*versio:2.05*/if (!defined('determinator')){ content goes here}?> Now i want to scan all... (6 Replies)
Discussion started by: devp
6 Replies

3. Shell Programming and Scripting

Perl regex to remove a segment in a line

Hello, ksh on Sun5.8 here. I have a pipe-delimited, variable length record file with sub-segments identified with a tilda that we receive from a source outside of our control. The records are huge, and Perl seems to be the only shell that can handle the huge lines. I am new to Perl, and am... (8 Replies)
Discussion started by: gary_w
8 Replies

4. Shell Programming and Scripting

find -regex option

I'm trying to use regular expression arguments as variables. I have to surround the regular expression with double quotes or else it automatically expands that regular expression to whatever is in that directory. Unfortunately when I run 'find' it further surrounds the double quotes with single... (6 Replies)
Discussion started by: stevensw
6 Replies

5. Shell Programming and Scripting

regex help with 'find'

How to do alternation using regular expressions in the 'find' command? Like say you want to find all files that do not match the names specifically "this" or "that" within a directory using regular expressions? (10 Replies)
Discussion started by: stevensw
10 Replies

6. Shell Programming and Scripting

Find regex

Hi There, Can anybody help me out for searching this regular expression? xxxxx.yyy.zzzz.From-ABCD.To-XYZ.xxxxxx I would like the ID1 and ID2 (knowing which one is Id1 and id2) .From-<ID1>. and .To-<ID2>. Thanks in advance!! Regards, Bhaskar (4 Replies)
Discussion started by: bhaskar_m
4 Replies

7. Shell Programming and Scripting

Using Sed to remove part of line with regex

Greetings everyone. Right now I am working on a script to be used during automated deployment of servers. What I have to do is remove localhost.localdomain and localhost6.localdomain6 from the /etc/hosts file. Simple, right? Except most of the examples I've found using sed want to delete the entire... (4 Replies)
Discussion started by: msarro
4 Replies

8. Shell Programming and Scripting

Regex to remove subdirectory

I need to remove subdirectories that are empty and I've not done this before. First I am going through the files to remove old records. Then if the directory is empty I want to delete it. There are files in /direcotry/images/fs* - 0-9 and a-z The fs* directories need to stay, but any directories... (4 Replies)
Discussion started by: janel10
4 Replies

9. Shell Programming and Scripting

regex to remove commentaries and blanks

Hi all, I need to prune a var's content as follows: VAR='blah blah # seew seew' NEWVAR='blah blah' (without blanks) I need also to perform this change by using variable substitution within bash shell. I've tried it with the following subst: VAR2=${VAR/ \#*/} but the... (7 Replies)
Discussion started by: yomaya
7 Replies

10. Shell Programming and Scripting

Find with RegEx

I have some files in unix ls -1 TMH.backend.tar.421E-03.Z TMH.backend.tar.421E-04.Z TMH.backend.tar.421E-05.Z TMH.backend.tar.421E-06.Z TMH.backend.tar.421E-07.Z TMH.backend.tar.421E-08.Z TMH.backend.tar.421E-08.Z.bak20081223164844 TMH.backend.tar.421E-09.Z... (1 Reply)
Discussion started by: on9west
1 Replies
Login or Register to Ask a Question