Removing single line comments in a file
2 answers
sed -e 's|/\*.*\*/||g' => to remove /* ... */
sed -e 's|//.*||g' => to remove //...
sed -e 's|/\*.*\*/||g' -e 's|//.*||g' => to remove both /* ... */ and //...
Example:
sdlcb@ubuntu:~$ cat file
jksdjskjdsd /* jdskdskd */
jdskdjsd // ksldksldsdks
uiiu
sdlcb@ubuntu:~$ sed -e 's|/\*.*\*/||g' -e 's|//.*||g' file
jksdjskjdsd
jdskdjsd
uiiu
+1
source to share