Removing a pattern in a line

Dear team,

I have a file curve.csv which is generated from oracle and each line has a comment associated with it, I want to get rid of this comment, can you please suggest me a command as how to do it
Eg,

cat curve.csv
/*data for today curve*/
/*data for text1*/ this is the header
/*data for text2*/ this is the body

the output that I want it

cat curve.csv
this is the header
this is the body

there is no requirement for comment, can you please suggest?
Thanks

$ awk 'gsub(/\/\*.*\*\//,x) + 1' curve.csv
1 Like

Longhand using CygWin default bash terminal:-

(Note I have not bothered to remove the leading newline as that is easy.)

#!/bin/bash
> /tmp/comment
> /tmp/nocomments
ifs_str="$IFS"
IFS="/"$'\n'
echo '/*data for today curve*/
/*data for text1*/ this is the header
/*data for text2*/ this is the body' >> /tmp/comment
while read line
do
	text=($line)
	echo "${text[2]:1}" >> /tmp/nocomments
done < /tmp/comment
cat < /tmp/nocomments
IFS="$ifs_str"
exit 0

Resuilts:-

AMIGA:~> cd /tmp
AMIGA:/tmp> chmod 755 comment.sh
AMIGA:/tmp> ./comment.sh

this is the header
this is the body
AMIGA:/tmp> _
1 Like

Another way,

while read line
do
 [ "${line##*/}" ] && echo ${line##*/}
done < file

Note, That check is for if theres only comment and no text in the line, don't print it.

The trouble with these C-Style comments is that they can span multiple lines and that if the comment characters are embedded in quotation marks then they should not be regarded as comments.

1 Like

Problem with this code is, its deleting the line if its finding the comment on right side of the file, I am in need to remove only /<any text number etc>/
this is not working if the line is

this is the first line  /*print first line*/

---------- Post updated at 07:32 PM ---------- Previous update was at 07:31 PM ----------

Hi, i am using Solaris, so this is not working

Then please give us a few lines of genuine text for us to play with.
As Scrutinizer has quoted......

......then without the full facts we __can__ pre-empt a possible set of events but this will change the structure from simple to complex...

Once again please post a few lines of genuine text with any private stuff removed.