Finish your work more efficiently
With linux's built in tool, we can do our work more efficiently. For instance, we want to create 50 user directories, tons way can do the task.
a perl version:
#!/usr/bin/perl
foreach i (1..50)
{
mkdir("user$_",0744);
# or use the system() function
System(`mkdir user$_");
}
while we can do this with shell, but it only fits :
for i in {1,2,3,4,5,6,7}; do mkdir user$i;done
Perl liner seems to be the best solution for this kind of task (only one line and we can set permission, isn't it great!)
perl -e 'for(1..6) {mkdir("user$_",0744)}'
Of course perl is not only option, python, ruby, C or whatever you like can do a good job. A lot of folks would rather spend whole of time on begging around for 'automated' software, hack up your brain, hack your system, answer is always there for you.
No comments:
Post a Comment