Discussion: remove text
Afficher un message
Vieux 17/05/2007, 20h43   #3
Chris F.A. Johnson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: remove text

On 2007-05-17, Ivan wrote:
> Hi all..
>
> I'm in need of some .
> I currently manage a subversion server with many repositories and many
> users in the repositories.
> When a user no longer requires access to any repo, I have to go into
> each repo one by one and remove their name.
> The password file is a simple text file located at */conf/passwd
>
> Is there a way that a script can search through all repos and delete
> each occurrence of the user?
>
> for example, I can find out which repository the user is a member of
> by doing:
> grep -l "dan" */conf/passwd


grep -l "^dan:" */conf/passwd

> This will look through each repo and print the subdirectory of the
> group of which dan is a member of.
>
> How can I then automatically remove his name?
>
> I don't know the command I need to use -- if someone can tell me the
> command I can build the script..


grep -v "^dan:" "$file" > tempfile && mv tempfile "$file"

Or:

sed '/^dan:/d' "$file" > tempfile && mv tempfile "$file"

Or:

awk '/^dan:/ { next } { print }' > tempfile && mv tempfile "$file"


--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell/>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
  Réponse avec citation
 
Page generated in 0,05711 seconds with 9 queries