Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
grep is really only for finding matches; it doesn't do anything by way of replacing. sed (stream editor) is probably closer to what you're looking for. perl can also do it fairly easily, if you have that installed. Check out Searching and Replacing (Linux Cookbook).
# perl -pi -e "s/htmlentities//g;" *
Can't do inplace edit: bilder is not a regular file, <> line 16878.
Can't do inplace edit: bin is not a regular file, <> line 16878.
Can't do inplace edit: config is not a regular file, <> line 17596.
Can't do inplace edit: convert is not a regular file, <> line 17596.
Can't do inplace edit: coursefiles is not a regular file, <> line 19358.
Can't do inplace edit: data is not a regular file, <> line 20176.
Can't do inplace edit: docs is not a regular file, <> line 21547.
Can't do inplace edit: help is not a regular file, <> line 42565.
Can't do inplace edit: html is not a regular file, <> line 42717.
Can't do inplace edit: imagemaps is not a regular file, <> line 42717.
Can't do inplace edit: images is not a regular file, <> line 42717.
Can't do inplace edit: include is not a regular file, <> line 42717.
Can't do inplace edit: lang is not a regular file, <> line 45212.
Can't do inplace edit: lib is not a regular file, <> line 47790.
Can't do inplace edit: libexec is not a regular file, <> line 47790.
Can't do inplace edit: log is not a regular file, <> line 47923.
Can't do inplace edit: logos is not a regular file, <> line 48022.
Can't do inplace edit: low_cat is not a regular file, <> line 48068.
Can't do inplace edit: man is not a regular file, <> line 49750.
Can't do inplace edit: modules is not a regular file, <> line 50716.
Can't do inplace edit: mysqldata is not a regular file, <> line 50716.
Can't do inplace edit: objects is not a regular file, <> line 52353.
Can't do inplace edit: plugins is not a regular file, <> line 53010.
Can't do inplace edit: sonderzeichen is not a regular file, <> line 53015.
Can't do inplace edit: sql is not a regular file, <> line 53015.
Can't do inplace edit: src is not a regular file, <> line 53015.
Can't do inplace edit: syntax_highlight is not a regular file, <> line 54906.
Can't do inplace edit: templates is not a regular file, <> line 54906.
Can't do inplace edit: tmp is not a regular file, <> line 54922.
Can't do inplace edit: www is not a regular file, <> line 57175.
It looks like it's giving errors on all the directory names; I don't think that command will do replacing on directories, just on the files that are in the current directory. You could do all the subdirectories manually, but that would be a pain if there are a lot of them. An easier way would be to use a find command on all the files you want to replace (for example, all *.html files), and then run sed on each one. Something like this:
find . -name '*.html' -exec sed -e "s/htmlentities//g;"
The first part (find . -name '*.html') finds all files in the current directory and all subdirectories with an html extension. The second part (-exec and so on) tells find to run the given sed command on each file it finds. I'm not sure about the syntax, so you may want to search around for sed howtos.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.