Sponsored Content
Top Forums Shell Programming and Scripting Deleting comments from c-file Post 302571734 by jayan_jay on Tuesday 8th of November 2011 06:09:09 AM
Old 11-08-2011
For your above posted input file ..
Code:
$ sed '/\/\*$/,/\*\/$/d' infile.cpp

This User Gave Thanks to jayan_jay For This Post:
 

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. UNIX for Dummies Questions & Answers

Delete Comments in file

How can I delete comments (lines beginning with /* and ending with */) in file? with single command line..My suggestion is to use grep and sed! (4 Replies)
Discussion started by: aadi_uni
4 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

Remove blank lines and comments from text file

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

7. 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

8. 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

9. Shell Programming and Scripting

Deleting comments from fields

Hi I have this sample data set as follows (called file.txt): hostname1:user1:password hostname2:user1:password #comments comments hostname3:user1:passwordI wish to produce a report as follows: hostname1 user1 password hostname2 user1 password hostname3 user1 passwordie remove all... (11 Replies)
Discussion started by: tsu3000
11 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
PMGENMAP(1)						      General Commands Manual						       PMGENMAP(1)

NAME
pmgenmap - generate C code to simplify handling of performance metrics SYNOPSIS
pmgenmap [infile] DESCRIPTION
Given one or more lists of metric names in infile or on standard input, pmgenmap generates C declarations and cpp(1) macros suitable for use across the Performance Metrics Programming Interface (PMAPI) on standard output. The declarations produced by pmgenmap simplify the coding for client applications using the PMAPI. The input should consist of one or more lists of metric names of the form listname { metricname1 symbolname1 metricname2 symbolname2 ... } which will generate C and cpp(1) declarations of the form char *listname[] = { #define symbolname1 0 "metricname1", #define symbolname2 1 "metricname2", ... }; The array declarations produced are suitable as parameters to pmLookupName(3) and the #defined constants may be used to index the vsets in the pmResult structure returned by a pmFetch(3) call. Obviously, listname must conform to the C identifier naming rules, each symbolname must conform to the cpp(1) macro naming rules, and each metricname is expected to be a valid performance metrics name (see pmns(5) for more details). The input may include sh-style comment lines, i.e. with a `#' as the first non-blank character of a line, and these are translated on out- put to either single line or multi-line C comments in the K&R style. For example, the input: # leading block of multi-line comments # initialization group foo { a.b.c ONE d.e.f.g TWO # embedded block of multi-lines # comments and boring pad text xx.yy.zz THREE } # trailing single line comment Produces the output: /* * leading block of multi-line comments * initialization group */ char *foo[] = { #define ONE 0 "a.b.c", #define TWO 1 "d.e.f.g", /* * embedded block of multi-lines * comments and boring pad text */ #define THREE 2 "xx.yy.zz", }; /* trailing single line comment */ EXAMPLE
For brevity we have removed the error handling code, and assumed the chosen metrics do not have multiple values. The input file mystats { kernel.percpu.cpu.idle IDLE kernel.percpu.cpu.sys SYS kernel.percpu.cpu.user USER hinv.ncpu NCPU } produces the following C code, suitable for #include-ing /* * Performance Metrics Name Space Map * Built by pmgenmap from the file * mystats.metrics * on Wed Dec 28 19:44:17 EST 1994 * * Do not edit this file! */ char *mystats[] = { #define IDLE 0 "kernel.percpu.cpu.idle", #define SYS 1 "kernel.percpu.cpu.sys", #define USER 2 "kernel.percpu.cpu.user", #define NCPU 3 "hinv.ncpu", }; Using the code generated by pmgenmap, we are now able to easily obtain metrics from the Performance Metrics Collection Subsystem (PMCS) as follows: #define MAX_PMID 4 int trip = 0; int numpmid = sizeof(mystats)/sizeof(mystats[0]); double duration; pmResult *resp; pmResult *prev; pmID pmidlist[MAX_PMID]; pmNewContext(PM_CONTEXT_HOST, "localhost"); pmLookupName(numpmid, mystats, pmidlist); pmFetch(numpmid, pmidlist, &resp); printf("%d CPUs: %d usr %d sys %d idle0, resp->vset[NCPU]->vlist[0].value.lval, resp->vset[USER]->vlist[0].value.lval, resp->vset[SYS]->vlist[0].value.lval, resp->vset[IDLE]->vlist[0].value.lval); Some calls to ensure portability have been removed from the code above for the sake of clarity - the example above should not be used as a template for programming. In particular, the raw values of the metrics were used when pmLookupDesc(3) should have been called to determine the semantics of each metric. More complete examples that demonstrate the use of pmgenmap which may be used as a basis for program development are included in the PCP demos, e.g. $PCP_DEMOS_DIR/pmclient. FILES
$PCP_VAR_DIR/pmns/* default PMNS specification files PCP ENVIRONMENT
Environment variables with the prefix PCP_ are used to parameterize the file and directory names used by PCP. On each installation, the file /etc/pcp.conf contains the local values for these variables. The $PCP_CONF variable may be used to specify an alternative configura- tion file, as described in pcp.conf(5). SEE ALSO
cpp(1), PMAPI(3), pmFetch(3), pmLookupName(3), pmNewContext(3), pcp.conf(5), pcp.env(5) and pmns(5). Performance Co-Pilot PCP PMGENMAP(1)
All times are GMT -4. The time now is 10:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy