Danny Watson
Danny Watson

Reputation: 165

SED cannot open subdirectory

I have written some code that checks all the folders in the file and matches a regex statement to them however, there is a subfolder in the directory that I want it to enter and also perform the regex on but whenever I run the code it gives me this error

sed: couldn't edit TestFolder: not a regular file

I've looked all over S.O and the Internet and can't find anything helpful

I've tried to use code I've found to fix my problem but it isn't helping so I apologise for the potentially hideous code, it's pulled from various sources

`pwd = "$PWD"
find $pwd = -print | xargs -0 sed -i "/10.0.0.10/d" !(test.sh)

My directory structure follows

Test -one.txt -two.txt TestFolder -three.txt

Upvotes: 0

Views: 56

Answers (1)

Ed Morton
Ed Morton

Reputation: 203129

With GNU find, GNU xargs, and GNU sed:

find . -type f -not -name 'test.sh' -print0 | xargs -0 sed -i '/\<10\.0\.0\.10\>/d'

Upvotes: 2

Related Questions