Sed exclude directories

I am trying to replace multiple files at once with sed, using * as the file name. However, it also tries to process directories and gives an error and terminates. Is there an easy way to overcome this?

+6
sed
source share
1 answer

I'm not sure exactly how you use sed here, but the usual way to process only regular files on UNIX is with the find , something like:

 find . -type f -exec sed 's/Hello/Goodbye/g' {} ';' 

The type restricts you to regular files, not directories or FIFOs or any other file system magic.

If you run man find on your system, you will see many other options that you can use.

+9
source share

All Articles