|
|
|
|
|||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
preserving file permissions on search+replace
Friday 1 August 2008 00:01, Grant wrote:
Hi there, > I have a couple problems with a bash script on linux: a) not preserving permissions, and b) overwriting a symlink (although I can avoid this by using the symlink target). > script: > #!/bin/bash # [ $1 = "" ] && echo "Usage: $0 filename" && exit > tmp=$(mktemp) || exit > awk ' /search_term/ { sub(/search_term/, "replace_term") } 1' $1 $tmp && mv $tmp $1 Try with cp "$1" "$tmp" awk '' "$tmp" "$1" -- All the commands are tested with bash and GNU tools, so they may use nonstandard features. I try to mention when something is nonstandard (if I'm aware of that), but I may miss something. Corrections are welcome. |
![]() |
| Viewing: Web Development Archives > FAQs > Unix/Linux > preserving file permissions on search+replace |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|