PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > remove text
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

remove text

Réponse
 
LinkBack Outils de la discussion
Vieux 17/05/2007, 03h47   #1
Ivan
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut remove text

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

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..

  Réponse avec citation
Vieux 17/05/2007, 05h38   #2
Ed Morton
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: remove text

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


That would produce a false "hit" if "daniel" appeared anywhere in the
file or if "dan" just happened to appear somewhere other than the "user
id" field. If the file is colon-delimited fields and the user id occurs
in, say, the first field, then this would be more accurate:

awk -F: '$1 == "dan"{print FILENAME}' */conf/passwd

> This will look through each repo and print the subdirectory of the
> group of which dan is a member of.


dan or daniel or rodan or....

> How can I then automatically remove his name?


for file in */conf/passwd
do
awk -F: '$1 == "dan"{next}1' "$file" > tmp &&
mv tmp "$file"
done

> I don't know the command I need to use -- if someone can tell me the
> command I can build the script..


Regards,

Ed.
  Réponse avec citation
Vieux 17/05/2007, 19h43   #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
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 22h27.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,08532 seconds with 11 queries