06-22-2012
I mean the script where you want to remove the comments...not the script that removes the comments.
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
Is there a way that I can use sed to remove lines with css comments like this?
/* comment */ (9 Replies)
Discussion started by: gravesit
9 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. 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
9. Shell Programming and Scripting
As I stated in a previous thread - I'm a newbie to Unix/Linux and programming. I'm trying to learn the basics on my own using a couple books and the exercises provided inside.
I've reached an exercise that has me stumped. I need to write a bash script that will will read in a file and print the... (11 Replies)
Discussion started by: ksmarine1980
11 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
UNIFDEF(1) General Commands Manual UNIFDEF(1)
NAME
unifdef - remove ifdef'ed lines
SYNOPSIS
unifdef [ -t -l -c -Dsym -Usym -idsym -iusym ] ... [ file ]
DESCRIPTION
Unifdef is useful for removing ifdef'ed lines from a file while otherwise leaving the file alone. Unifdef is like a stripped-down C pre-
processor: it is smart enough to deal with the nested ifdefs, comments, single and double quotes of C syntax so that it can do its job, but
it doesn't do any including or interpretation of macros. Neither does it strip out comments, though it recognizes and ignores them. You
specify which symbols you want defined -Dsym or undefined -Usym and the lines inside those ifdefs will be copied to the output or removed
as appropriate. The ifdef, ifndef, else, and endif lines associated with sym will also be removed. Ifdefs involving symbols you don't
specify are untouched and copied out along with their associated ifdef, else, and endif lines. If an ifdef X occurs nested inside another
ifdef X, then the inside ifdef is treated as if it were an unrecognized symbol. If the same symbol appears in more than one argument, only
the first occurrence is significant.
The -l option causes unifdef to replace removed lines with blank lines instead of deleting them.
If you use ifdefs to delimit non-C lines, such as comments or code which is under construction, then you must tell unifdef which symbols
are used for that purpose so that it won't try to parse for quotes and comments in those ifdef'ed lines. You specify that you want the
lines inside certain ifdefs to be ignored but copied out with -idsym and -iusym similar to -Dsym and -Usym above.
If you want to use unifdef for plain text (not C code), use the -t option. This makes unifdef refrain from attempting to recognize com-
ments and single and double quotes.
Unifdef copies its output to stdout and will take its input from stdin if no file argument is given. If the -c argument is specified, then
the operation of unifdef is complemented, i.e. the lines that would have been removed or blanked are retained and vice versa.
SEE ALSO
diff(1)
DIAGNOSTICS
Premature EOF, inappropriate else or endif.
Exit status is 0 if output is exact copy of input, 1 if not, 2 if trouble.
BUGS
Does not know how to deal with cpp consructs such as
#if defined(X) || defined(Y)
AUTHOR
Dave Yost
4.3 Berkeley Distribution April 29, 1985 UNIFDEF(1)