Here’s one way using GNU sed
. Run like sed -rf script.sed file.txt
Contents of script.sed
:
:a
s%(.*)/\*.*\*/%\1%
ta
/\/\*/ !b
N
ba
Alternatively, here’s the one liner:
sed -r ':a; s%(.*)/\*.*\*/%\1%; ta; /\/\*/ !b; N; ba' file.txt
More Related Contents:
- Remove non-ASCII characters from CSV
- Insert a line at specific line number with sed or awk
- Remove line if field is duplicate
- delete a column with awk or sed
- remove ^M characters from file using sed
- How to use awk to print lines where a field matches a specific string?
- What is the difference between sed and awk? [closed]
- Enhancement of unix script [closed]
- shell – remove numbers from a string column [closed]
- Printing with sed or awk a line following a matching pattern
- sed fails with “unknown option to `s'” error [closed]
- How can I do a recursive find/replace of a string with awk or sed?
- Why does my tool output overwrite itself and how do I fix it?
- How can I delete a newline if it is the last character in a file?
- Shell variables in sed script
- Remove first N lines of a file in place in unix command line
- How to add to the end of lines containing a pattern with sed or awk?
- Change multiple files
- Batch script to replace PHP short open tags with
- Easiest way to extract the urls from an html page using sed or awk only
- Sed to extract text between two strings
- How to remove double-quotes in jq output for parsing json files in bash?
- Insert multiple lines into a file after specified pattern using shell script
- How to find/replace and increment a matched number with sed/awk?
- Remove all lines before a match with sed
- sed gives me “: unexpected EOF (pending }’s) error and I have no idea why
- Have sed ignore non-matching lines
- Grep output with multiple Colors?
- using bash (sed/awk) to extract rows AND columns in CSV files?
- How to grep for case insensitive string in a file?