Reputation: 3391
I need to delete all comments inside all script files in the current folder and sub folders. All comment lines start with //. I want to delete the whole line
Upvotes: 0
Views: 971
Reputation: 195059
find . -type f |xargs sed -i '\#^//#d'
the find part find all files, and the sed
part removes all lines starting with //
You can add -name
option in find
to do further filtering. check man find
to get more useful information.
Your pattern contains slash /
, so with sed's default /pattern/d
you have to do some escaping. I used #
as delimiter to save that kind of works, and made the code easier to read.
Upvotes: 4