Код: Выделить всё
sed -e "s/DIST_SUBDIR/\#DIST_SUBDIR/g" `find /usr/ports -type f -name Makefile`
Код: Выделить всё
sed -e "s/DIST_SUBDIR/\#DIST_SUBDIR/g" `find /usr/ports -type f -name Makefile`
Всё правильно.manefesto писал(а):Вообщем у меня есть вот такая маленькая связочка:Но почему после выполнения этой команды у меня в Makefile не происходят изминения, хотя в stdout они выводятся и вроде бы есть, а когда заглядываю в сам Makefile то там без изминенийКод: Выделить всё
sed -e "s/DIST_SUBDIR/\#DIST_SUBDIR/g" `find /usr/ports -type f -name Makefile`
Код: Выделить всё
#!/bin/sh
for i in `find /usr/ports -type f -name Makefile`; do
echo "search in $i"
cat /dev/null > /tmp/tmp.port
sed -e "s/DIST_SUBDIR/#DIST_SUBDIR/g" $i >> /tmp/tmp.port
cat /tmp/tmp.port > $i
done
manefesto писал(а):Вообщем ХЗ что там и где написано. Читал русские маны, вообщем просветление не пришло поэтому переписал следующим образом:
PS: Если не сложно чиркни как будет правильно только с использование sedКод: Выделить всё
#!/bin/sh for i in `find /usr/ports -type f -name Makefile`; do echo "search in $i" cat /dev/null > /tmp/tmp.port sed -e "s/DIST_SUBDIR/#DIST_SUBDIR/g" $i >> /tmp/tmp.port cat /tmp/tmp.port > $i done
То есть вывод надо перенаправлять обратно в файл, что у Вас и сделано. Должно работать как надо.man sed писал(а):DESCRIPTION
The sed utility reads the specified files, or the standard input if no
files are specified, modifying the input as specified by a list of com-
mands. The input is then written to the standard output.
manefesto писал(а):Вообщем у меня есть вот такая маленькая связочка:Но почему после выполнения этой команды у меня в Makefile не происходят изминения, хотя в stdout они выводятся и вроде бы есть, а когда заглядываю в сам Makefile то там без изминенийКод: Выделить всё
sed -e "s/DIST_SUBDIR/\#DIST_SUBDIR/g" `find /usr/ports -type f -name Makefile`
sed(1) писал(а): -I extension
Edit files in-place, saving backups with the specified extension.
If a zero-length extension is given, no backup will be saved. It
is not recommended to give a zero-length extension when in-place
editing files, as you risk corruption or partial content in situ-
ations where disk space is exhausted, etc.
Note that in-place editing with -I still takes place in a single
continuous line address space covering all files, although each
file preserves its individuality instead of forming one output
stream. The line counter is never reset between files, address
ranges can span file boundaries, and the ``$'' address matches
only the last line of the last file. (See Sed Addresses.) That
can lead to unexpected results in many cases of in-place editing,
where using -i is desired.
-i extension
Edit files in-place similarly to -I, but treat each file indepen-
dently from other files. In particular, line numbers in each
file start at 1, the ``$'' address matches the last line of the
current file, and address ranges are limited to the current file.
(See Sed Addresses.) The net result is as though each file were
edited by a separate sed instance.
Код: Выделить всё
-sed -e "s/DIST_SUBDIR/\#DIST_SUBDIR/g" `find /usr/ports -type f -name Makefile`
+find /usr/ports/ -type f -name Makefile -exec sed -i "" "s/DIST_SUBDIR/ #DIST_SUBDIR/g" {} +