Sed removes the first line from files

I want to delete the first line of all files in a folder if the file starts with uuid, and so I have a working command sedthat looks like this:

$ sed -i '' '/^uuid/d' *

which works fine and removes all lines starting with uuid.

Now I want to improve the script by deleting only the first line if it starts with uuid, as some files have several uuid: s, and only one in the first line should be deleted. So now I have improved the command to look like this:

$ sed -i '' '1{/^uuid/d;}' *

Now this command also works, but only in the first file in the folder and even if I run a simple (just delete the first line) version, for example:

$ sed -i '' '1d' *

it still affects only the first file.

Why is this?

Mac ( BSD- sed, ), gnu-sed Brew, $ brew install gnu-sed --with-default-names, .

sed - 25 , sed - 20 / googled sed

1: john1024, -s, , .

$ sed -s '1d' ./* sed: illegal option -- s

man sed, -s & --seperate, - .

2: , ... find . -iname '*.yml' -exec sed -i '' -e '1{/uuid/d;}' {} \; , sed: can't read : No such file or directory

!

:

+4
1

sed -i '' '1{/^uuid/d;}' * , , " 1" , . - , sed .

, for:

for f in *; do sed -i '' '1{/^uuid/d;}' "$f"; done
+2

Source: https://habr.com/ru/post/1690493/


All Articles