Sponsored Content
Full Discussion: Delete Comments in file
Top Forums UNIX for Dummies Questions & Answers Delete Comments in file Post 302369519 by juststarted on Monday 9th of November 2009 12:20:08 AM
Old 11-09-2009
sed command to remove comments

Hello,

i am replying rather old post, but i have the similar problem with slight variation.

when i use command:

sed '/*,*/d' somefile.c

suppose the file somefile.c contains
line

/* this is an example */

its removing comeplete line but when i have a line

/*
this is an example
*/
its removing only /* and */
and not the text between /* and */

i can easily implement the commad using command line arguments.
but i want to know is there any command that deletes the entire characters present under /* and */ when they are in different lines.

Thanks,
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

removing comments from file

I'm doing manual way to add and remove "#" on etc/services. Is there anyway I can modify the file using awk or sed or any other program. I use vi to modify /etc/services for enabling telnet , the problem is I don't know how to do it automatically in script. production state: #telnet ... (9 Replies)
Discussion started by: skully
9 Replies

2. UNIX for Advanced & Expert Users

Add Comments to the specifi lines i na file

I have a requirement like below.I need to Comment some lines in a file. File contains following information. { attribute1 attribute2 atrribute3 attribute4 attribute5 attribute6 attribute7 } I have a requirement like some times i need to comment lines 3 to before '}' and some... (1 Reply)
Discussion started by: ukatru
1 Replies

3. Shell Programming and Scripting

AWK to skip comments in XML file

Hello, I'm trying to make a shell script to skip comments from an XML file, but with the code below only deletes comments that are in one line. Can you tell me what can be added here? nawk ' { if($0 !~/<!--/) { a=0 } if($0 ~/<!--/ && $0 ~/-->/) {a=1} if($0 ~/<!--/) {a=1} if... (1 Reply)
Discussion started by: majormark
1 Replies

4. Shell Programming and Scripting

delete comments

Delete everything comes in between /* & */. Current File: ==================== create or replace procedure test421 is begin /* ---sasasas/*dsdsds */ dbms_output.put_line('SAURABH'); END; To be File: =================== create or replace procedure test421 is begin... (10 Replies)
Discussion started by: susau_79
10 Replies

5. Shell Programming and Scripting

Sed script, changing all C-comments to C++-comments

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

6. UNIX for Dummies Questions & Answers

Delete Comments

Hello i am back :D, i have a prolem. I want to Delete the IPs which are in Comments. Input 192.168.0.1 192.168.0.2 #192.168.0.3 #192.168.0.4 - when TAB or Space, delete too. /*192.168.0.5 192.168.0.6 192.168.0.7*\ Output 192.168.0.1 192.168.0.2 My solution is sed -e... (7 Replies)
Discussion started by: eightball
7 Replies

7. Shell Programming and Scripting

Deleting comments from c-file

hii all, i am writing a shell script to remove comments from a .c/.cpp file. i have written script as the above script file deletes line between /* and */ also lines starting with //. but the problems are : 1) i dont want to delete the content between /** and */. 2)sed -i... (16 Replies)
Discussion started by: yashwantkumar
16 Replies

8. Linux

Not able to sort a file based on it name. Need your expert comments.

Hi, I have a files as shown below and I wanted to sort then in following patter based on there names which has "_" in it. I want to sort them according to feild 6th (bold once)value as shown below. Thanks in advance. File names: 20111014_manish_STEP2_Files_number__5979-6968_ ... (5 Replies)
Discussion started by: manishkomar007
5 Replies

9. Shell Programming and Scripting

Remove comments from file with specific file name extensions

Hello Unix board community, I have to program a shell script, but I am a complete noob so I hope I get some help here. The assignment is as follows: The program removes all comments regardless of formatting or language from files with specific file name extensions (php, css, js, ...).... (3 Replies)
Discussion started by: TheZeusMan
3 Replies

10. Shell Programming and Scripting

Bash script to find comments in file

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
erl_recomment(3erl)					     Erlang Module Definition					       erl_recomment(3erl)

NAME
erl_recomment - Inserting comments into abstract Erlang syntax trees. DESCRIPTION
Inserting comments into abstract Erlang syntax trees This module contains functions for inserting comments, described by position, indentation and text, as attachments on an abstract syntax tree, at the correct places. EXPORTS
quick_recomment_forms(Tree::Forms, Comments::[Comment]) -> syntaxTree() Types Forms = syntaxTree() | [syntaxTree()] Comment = {Line, Column, Indentation, Text} Line = integer() Column = integer() Indentation = integer() Text = [string()] Like recomment_forms/2 , but only inserts top-level comments. Comments within function definitions or declarations ("forms") are simply ignored. recomment_forms(Tree::Forms, Comments::[Comment]) -> syntaxTree() Types syntaxTree() (see module erl_syntax) Forms = syntaxTree() | [syntaxTree()] Comment = {Line, Column, Indentation, Text} Line = integer() Column = integer() Indentation = integer() Text = [string()] Attaches comments to the syntax tree/trees representing a program. The given Forms should be a single syntax tree of type form_list , or a list of syntax trees representing "program forms". The syntax trees must contain valid position information (for details, see recomment_tree/2 ). The result is a corresponding syntax tree of type form_list in which all comments in the list Comments have been attached at the proper places. Assuming Forms represents a program (or any sequence of "program forms"), any comments whose first lines are not directly associated with a specific program form will become standalone comments inserted between the neighbouring program forms. Furthermore, comments whose column position is less than or equal to one will not be attached to a program form that begins at a conflicting line number (this can happen with preprocessor-generated line -attributes). If Forms is a syntax tree of some other type than form_list , the comments will be inserted directly using recomment_tree/2 , and any comments left over from that process are added as postcomments on the result. Entries in Comments represent multi-line comments. For each entry, Line is the line number and Column the left column of the comment (the column of the first comment-introducing " % " character). Indentation is the number of character positions between the last non-whitespace character before the comment (or the left margin) and the left column of the comment. Text is a list of strings rep- resenting the consecutive comment lines in top-down order, where each string contains all characters following (but not including) the comment-introducing " % " and up to (but not including) the terminating newline. (Cf. module erl_comment_scan .) Evaluation exits with reason {bad_position, Pos} if the associated position information Pos of some subtree in the input does not have a recognizable format, or with reason {bad_tree, L, C} if insertion of a comment at line L , column C , fails because the tree structure is ill-formed. See also: erl_comment_scan , quick_recomment_forms/2 , recomment_tree/2 . recomment_tree(Tree::syntaxTree(), Comments::[Comment]) -> {syntaxTree(), [Comment]} Types Comment = {Line, Column, Indentation, Text} Line = integer() Column = integer() Indentation = integer() Text = [string()] Attaches comments to a syntax tree. The result is a pair {NewTree, Remainder} where NewTree is the given Tree where comments from the list Comments have been attached at the proper places. Remainder is the list of entries in Comments which have not been inserted, because their line numbers are greater than those of any node in the tree. The entries in Comments are inserted in order; if two comments become attached to the same node, they will appear in the same order in the program text. The nodes of the syntax tree must contain valid position information. This can be single integers, assumed to represent a line num- ber, or 2- or 3-tuples where the first or second element is an integer, in which case the leftmost integer element is assumed to represent the line number. Line numbers less than one are ignored (usually, the default line number for newly created nodes is zero). For details on the Line , Column and Indentation fields, and the behaviour in case of errors, see recomment_forms/2 . See also: recomment_forms/2 . AUTHORS
Richard Carlsson <richardc@it.uu.se > syntax_tools 1.6.7 erl_recomment(3erl)
All times are GMT -4. The time now is 06:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy