08-25-2010
sed remove css comments
Is there a way that I can use sed to remove lines with css comments like this?
/* comment */
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
It may be a no-brainer, but the answer is escaping me right now:
I'm trying to write a little script to remove all comments from .c source... I was thinking sed, but I'm not a very strong regexp user (e.g. I suck with sed).
I tried dumping the file into:
sed -e 's/\/\* * \*\///g'
and several... (1 Reply)
Discussion started by: LivinFree
1 Replies
2. Shell Programming and Scripting
#! /bin/sed -nf
# Remove C and C++ comments, by Brian Hiles (brian_hiles@rocketmail.com)
# Sped up (and bugfixed to some extent) by Paolo Bonzini (bonzini@gnu.org)
# Works its way through the line, copying to hold space the text up to the
# first special character (/, ", '). The original... (1 Reply)
Discussion started by: Priyaranjan
1 Replies
3. Shell Programming and Scripting
Suppose i have a file like this:
#bla bla
#bla bla bla bla bla
Bla
BLA
BLA BLA #bla bla
....
....
how can i remove all comments from every line,even if they are behind commands or strngs that are not comments?
any idea how i could do that using awk? (2 Replies)
Discussion started by: bashuser2
2 Replies
4. Shell Programming and Scripting
I must write a script to change all C++ like comments:
// this is a comment
to this one
/* this is a comment */
How to do it by sed? With file:
#include <cstdio>
using namespace std; //one
// two
int main() {
printf("Example"); // three
}//four
the result should be: (2 Replies)
Discussion started by: black_hawk
2 Replies
5. UNIX for Dummies Questions & Answers
Hi,
I am using BASH. How can I remove any lines in a text file that are either blank or begin with a # (ie. comments)? Thanks in advance.
Mike (3 Replies)
Discussion started by: msb65
3 Replies
6. Shell Programming and Scripting
Hi everyone,
I've got a problem with converting C comments ( /* */ ) into C++ style ( // ) in some source file with sed. So far I've dealt with comments on one line, but I don't know how to convert when it is over multiple lines ...
So I already have something like this:
comments.sed
... (8 Replies)
Discussion started by: kolage
8 Replies
7. Shell Programming and Scripting
I need to use sed to remove comments from files. I am using this, but it only works on comments that start at the beginning of the line.
sed /^"\/\/"/d
In most of the files I have comments like this:
code // Comments
or
tab // Comments (5 Replies)
Discussion started by: gravesit
5 Replies
8. Shell Programming and Scripting
I would like to remove comments from a bash script. In addition, I would like to remove lines that consist of only white spaces, and to remove blank lines.
#!/bin/bash
perl -pe 's/ *#.*$//g' $1 | grep -v ^]*$ | perl -pe 's/ +/ /g' > $2
#
# $1 INFILE
# $2 OUTFILE
The above code... (10 Replies)
Discussion started by: LessNux
10 Replies
9. UNIX for Dummies Questions & Answers
I have tried a lot, Need your help guys.
SAS Program:
data one ; /* Data step */
Input name $; /*Dec variables*/
I want to remove the commented part(/* Data step */) alone. I have tried using sed command but it is deleting the entire line itself. i need unix command to separate this and... (1 Reply)
Discussion started by: saaisiva
1 Replies
10. Shell Programming and Scripting
Hi , We need to remove comment like pattern from a code text. The possible comment expressions are as follows.
Input
BizComment : Special/*@
Name:bzt_53_3aea640a_51783afa_5d64_0
BizHidden:true
@*/
/* lookup Disease
Category Therapuetic Class */
a=b;... (6 Replies)
Discussion started by: VikashKumar
6 Replies
LEARN ABOUT MOJAVE
ppi::token::comment5.18
PPI::Token::Comment(3) User Contributed Perl Documentation PPI::Token::Comment(3)
NAME
PPI::Token::Comment - A comment in Perl source code
INHERITANCE
PPI::Token::Comment
isa PPI::Token
isa PPI::Element
SYNOPSIS
# This is a PPI::Token::Comment
print "Hello World!"; # So it this
$string =~ s/ foo # This, unfortunately, is not :(
bar
/w;
DESCRIPTION
In PPI, comments are represented by "PPI::Token::Comment" objects.
These come in two flavours, line comment and inline comments.
A "line comment" is a comment that stands on its own line. These comments hold their own newline and whitespace (both leading and trailing)
as part of the one "PPI::Token::Comment" object.
An inline comment is a comment that appears after some code, and continues to the end of the line. This does not include whitespace, and
the terminating newlines is considered a separate PPI::Token::Whitespace token.
This is largely a convenience, simplifying a lot of normal code relating to the common things people do with comments.
Most commonly, it means when you "prune" or "delete" a comment, a line comment disappears taking the entire line with it, and an inline
comment is removed from the inside of the line, allowing the newline to drop back onto the end of the code, as you would expect.
It also means you can move comments around in blocks much more easily.
For now, this is a suitably handy way to do things. However, I do reserve the right to change my mind on this one if it gets dangerously
anachronistic somewhere down the line.
METHODS
Only very limited methods are available, beyond those provided by our parent PPI::Token and PPI::Element classes.
line
The "line" accessor returns true if the "PPI::Token::Comment" is a line comment, or false if it is an inline comment.
SUPPORT
See the support section in the main module.
AUTHOR
Adam Kennedy <adamk@cpan.org>
COPYRIGHT
Copyright 2001 - 2011 Adam Kennedy.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
perl v5.18.2 2011-02-25 PPI::Token::Comment(3)