Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Remove multi line and single line comments Post 302848283 by krishmaths on Thursday 29th of August 2013 01:13:41 AM
Old 08-29-2013
Using awk

Code:
awk '!/^\/\*|\*\/$|^--/'  filename

Edit:
Noted that this needs correction if multi line comment spans across more than 2 lines

---------- Post updated at 10:43 AM ---------- Previous update was at 10:32 AM ----------

Please use the corrected code below

Code:
awk '/^--/ {next} /^\/\*/ && /\*\/$/{next} /^\/\*/{c=1;next} /\*\/$/{c=0;next} !c '  filename

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Multi-line output to single line

Hello, How can I take the following output: outputa outputb outputc and turn it into single line ouput, with a single space between each field like below: outputa outputb outputc (7 Replies)
Discussion started by: LinuxRacr
7 Replies

2. Shell Programming and Scripting

Merge multi-lines into one single line

Hi, Can anyone help me for merge the following multi-line log which beginning with a number and time: into one line. For each line need to delete the return and add a space. Please see the red color line. *****Original Log*****... (4 Replies)
Discussion started by: happyday
4 Replies

3. Shell Programming and Scripting

How to use Perl to merge multi-line into single line

Hi, Can anyone know how to use perl to merge the following multi-line information which beginning with "BAM" into one line. For each line need to delete the return and add a space. Please see the red color line. ******Org. Multi-line) BAM admin 101.203.57.22 ... (3 Replies)
Discussion started by: happyday
3 Replies

4. Shell Programming and Scripting

How to use Perl to join multi-line into single line

Hello, Did anyone know how to write a perl script to merge the multi-line into a single line where each line with start at timestamp Input--> timestamp=2009-11-10-04.55.20.829347; a; b; c; timestamp=2009-11-10-04.55.20.829347; aa; bb; cc; (5 Replies)
Discussion started by: happyday
5 Replies

5. Shell Programming and Scripting

Merge multi-line output into a single line

Hello I did do a search and the past threads doesn't really solve my issue. (using various awk commands) I need to combine the output from java -version into 1 line, but I am having difficulties. When you exec java -version, you get: java version "1.5.0_06" Java(TM) 2 Runtime... (5 Replies)
Discussion started by: flagman5
5 Replies

6. Shell Programming and Scripting

Multi lines to single line

HI, My input file contains the data as like below: A1234119993 B6271113 Bghjkjk A1234119992 B6271113hi Bghjkjkmkl the output i require is : A1234119993 B6271113 Bghjkjk A1234119992 B6271113hi Bghjkjkmkl Please help me in this. Thanks (6 Replies)
Discussion started by: pandeesh
6 Replies

7. Shell Programming and Scripting

Joining multi-line output to a single line in a group

Hi, My Oracle query is returing below o/p ---------------------------------------------------------- Ins trnas value a lkp1 x a lkp1 y b lkp1 a b lkp2 x b lkp2 y ... (7 Replies)
Discussion started by: gvk25
7 Replies

8. Shell Programming and Scripting

Removing SAS multi line comments in UNIX

i have to remove the commented (/* . . . .*/) part which starts in one line and ends in other.help me with generic code because i have 1000 to 10k lines code which i have to remove. data one; set work.temp; input name age; infile filename; /* dfsdf dsfs sdfdf dsdd sdfsf sdfsf sfs... (4 Replies)
Discussion started by: saaisiva
4 Replies

9. Shell Programming and Scripting

Help with reformat single-line multi-fasta into multi-line multi-fasta

Input File: >Seq1 ASDADAFASFASFADGSDGFSDFSDFSDFSDFSDFSDFSDFSDFSDFSDFSD >Seq2 SDASDAQEQWEQeqAdfaasd >Seq3 ASDSALGHIUDFJANCAGPATHLACJHPAUTYNJKG ...... Desired Output File >Seq1 ASDADAFASF ASFADGSDGF SDFSDFSDFS DFSDFSDFSD FSDFSDFSDF SD >Seq2 (4 Replies)
Discussion started by: patrick87
4 Replies

10. Shell Programming and Scripting

Multi line log files to single line format

I want to read the log file which was generate from other command . And the output was having multi line in log files for job name and server name. But i need to make all the logs on one line Source file 07/15/2018 17:02:00 TRANSLOG_1700 Server0005_SQL ... (2 Replies)
Discussion started by: ranjancom2000
2 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 11:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy