LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-30-2003, 01:45 PM   #1
haggertus
LQ Newbie
 
Registered: Oct 2003
Posts: 3

Rep: Reputation: 0
user script


i've got a ton of user accounts on my machine that start with "justin_"

I'm trying to figure out a way to write a shell script that will go through my users and any user that starts with "justin_" will be deleted.

Any help would be greatly appreciated!
 
Old 10-30-2003, 01:59 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Code:
deluser -r `awk -F: '/^justin_/ {print $1}'  /etc/passwd`
should do the trick :)

Cheers,
Tink
 
Old 10-30-2003, 02:07 PM   #3
ToniT
Senior Member
 
Registered: Oct 2003
Location: Zurich, Switzerland
Distribution: Debian/unstable
Posts: 1,357

Rep: Reputation: 47
In bash:
Code:
for i in `awk -F: '/^justin_/ {print $1}' /etc/passwd`; do echo deluser $i ; done
(be carefull with the quotes. There are two different types of them in previous command)

If you like the commands you see as output, remove the "echo" word so the commands are executed instead of printed to the screen.
 
Old 10-30-2003, 02:08 PM   #4
ToniT
Senior Member
 
Registered: Oct 2003
Location: Zurich, Switzerland
Distribution: Debian/unstable
Posts: 1,357

Rep: Reputation: 47
Someone was faster.
 
Old 10-30-2003, 02:26 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
But my solution won't kill them all :)

What was I thinking ;) ... I really do know
better, but I guess I'm distracted ;)

Cheers Toni,
Tink out
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
execute a script as a different user JordanH Linux - Software 3 02-08-2005 02:47 PM
how do I make sure that the user that is going to run the script is a root user??? nikold01 Linux - General 3 09-10-2004 07:54 AM
Run a script as a different user dtheorem Programming 5 11-05-2003 05:57 PM
shell script user not ok slam Linux - General 4 07-24-2003 06:40 AM
Create user script kelper Linux - Software 1 06-24-2003 09:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration