Re: adding multiple users, newuser? and vim
On Fri, Aug 24, 2001 at 05:38:56PM -0700, Mike Egglestone wrote:
> I have a txt file in this format:
>
> joe blow
> john smith
> john doe
>
> I would like to use "newusers" to add about 500 accounts to my system,
> but how do I quickly make the txt file look like this:
>
> joe_blow:password:1001:1001:,,,/home/joe_blow:/bin/bash
> john_smith:password:1002:1002:,,,/home/john_smith:bin/bash
Write a script to read stdin and print to stdout.
#!/usr/bin/perl
$pid=1000;
while (<STDIN>) {
chop;
$pid++;
($n1, $n2) = split / /;
print $n1,"_",$n2,":password:",$pid,
":",$pid,",,,/home/",$n1,"_",$n2,":/bin/bash\n"
}
I bet bash, sed, awk, python,... can do same thing...
--
~\^o^/~~~ ~\^.^/~~~ ~\^*^/~~~ ~\^_^/~~~ ~\^+^/~~~ ~\^:^/~~~ ~\^v^/~~~
+ Osamu Aoki <debian@aokiconsulting.com>, GnuPG-key: 1024D/D5DE453D +
+ My debian quick-reference, http://www.aokiconsulting.com/quick/ +
Reply to: