Sponsored Content
Top Forums Shell Programming and Scripting changing c comments to c++ style with sed Post 302431243 by kolage on Monday 21st of June 2010 08:15:52 AM
Old 06-21-2010
changing c comments to c++ style with sed

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
Code:
s/\/\*/\/\//g
s/\*\//&\n/g
/\/\/.*[^*\/\n]$/a\something

I actually pick first /* and substitute it for // and then after */ put newlines. After then I would remove the */ ones, but before that I've thought about putting // before every line in /* */ multiple comment, but I don't know how (so the 3rd line in the code is only some idea). Do you have any idea? I would be really glad.

Thanks for every reply.
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Changing text with sed?

Hi everyone, Having trouble with sed. I searched the board and found some stuff, but still unclear. I have a file named "userfile" which stores the users info in this form: email:username:password: I want the user to be able to change their password. i tried with sed s/oldpass/newpass/g... (2 Replies)
Discussion started by: primal
2 Replies

2. UNIX for Dummies Questions & Answers

Changing the order using sed

I have a text "abc def ghi" and I want to get it as "def abc ghi" I am using this echo "abc def ghi" | sed 's/\(*\)\(*\)/\2\1/' But I am not able to get the output, could anyone help me. Thanks (9 Replies)
Discussion started by: venu_nbk
9 Replies

3. Shell Programming and Scripting

sed and changing the file itself

hello I have this: sed -e "s/install_location=....../g" -e "s/hostname=....../g" -e "s/server_name=....../y" input.txt it will display on the screen what have changed. however I want to change file input.txt. Any idea other than doing redirection (>) thx (2 Replies)
Discussion started by: melanie_pfefer
2 Replies

4. Shell Programming and Scripting

awk, sed, grep...weird style

my desired output is like this: so the thing is, I only need to show every of this part out but the frequency of that data is not fixed, so sometimes it may have 4 lines, or 6 lines or whatever in that file. However, the last line will always have empty space/line below it. (13 Replies)
Discussion started by: finalight
13 Replies

5. Shell Programming and Scripting

please explain this sed shell script to remove C++ comments.

#! /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

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

7. Shell Programming and Scripting

sed remove css comments

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

8. Shell Programming and Scripting

sed remove comments

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

9. Shell Programming and Scripting

Changing time-stamp with sed

Hi ! I try to change a time-stamp hh:mm:ss allways to full ten-minutes. example: 12:51:03 to 12:50:03 sed 's/::/:{0-5}0:/g' file.txt but it will not work propperly, because the minute-decade will be replaced with the bracket-term {0-5}. Can someone please give me a hint? Thanks in... (6 Replies)
Discussion started by: IMPe
6 Replies
VORBISCOMMENT(1)						 Ogg Vorbis Tools						  VORBISCOMMENT(1)

NAME
vorbiscomment - List or edit comments in Ogg Vorbis files SYNOPSIS
vorbiscomment [-l] [-R] [-e] file.ogg vorbiscomment -a [ -c commentfile | -t "name=value" ] [-q] [-R] [-e] in.ogg [out.ogg] vorbiscomment -w [ -c commentfile | -t "name=value" ] [-q] [-R] [-e] in.ogg [out.ogg] DESCRIPTION
vorbiscomment Reads, modifies, and appends Ogg Vorbis audio file metadata tags. OPTIONS
-a, --append Append comments. -c file, --commentfile file Take comments from a file. The file is the same format as is output by the -l option or given to the -t option: one element per line in 'tag=value' format. If the file is /dev/null and -w was passed, the existing comments will be removed. -h, --help Show command help. -l, --list List the comments in the Ogg Vorbis file. -t 'name=value', --tag 'name=value' Specify a new tag on the command line. Each tag is given as a single string. The part before the '=' is treated as the tag name and the part after as the value. -w, --write Replace comments with the new set given either on the command line with -t or from a file with -c. If neither -c nor -t is given, the new set will be read from the standard input. -R, --raw Read and write comments in UTF-8, rather than converting to the user's character set. -e, --escapes Quote/unquote newlines and backslashes in the comments. This ensures every comment is exactly one line in the output (or input), allowing to filter and round-trip them. Without it, you can only write multi-line comments by using -t and you can't reliably dis- tinguish them from multiple one-line comments. Supported escapes are c-style " ", " ", "\" and "". A backslash followed by anything else is an error. Note: currently, anything after the first "" is thrown away while writing. This is a bug -- the Vorbis format can safely store null characters, but most other tools wouldn't handle them anyway. -V, --version Display the version of vorbiscomment. EXAMPLES
To just see what comment tags are in a file: vorbiscomment -l file.ogg To edit those comments: vorbiscomment -l file.ogg > file.txt [edit the comments in file.txt to your satisfaction] vorbiscomment -w -c file.txt file.ogg newfile.ogg To simply add a comment: vorbiscomment -a -t 'ARTIST=No One You Know' file.ogg newfile.ogg To add a set of comments from the standard input: vorbiscomment -a file.ogg ARTIST=No One You Know ALBUM=The Famous Album <ctrl-d> TAG FORMAT
See http://xiph.org/vorbis/doc/v-comment.html for documentation on the Ogg Vorbis tag format, including a suggested list of canonical tag names. AUTHORS
Program Authors: Michael Smith <msmith@xiph.org> Ralph Giles <giles@xiph.org> Manpage Author: Christopher L Cheney <ccheney@debian.org> SEE ALSO
oggenc(1), oggdec(1), ogg123(1), ogginfo(1) Xiph.Org Foundation December 30, 2008 VORBISCOMMENT(1)
All times are GMT -4. The time now is 09:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy