美文网首页linux基础知识
Linux批量创建用户讲解

Linux批量创建用户讲解

作者: 温东 | 来源:发表于2017-04-27 13:54 被阅读0次

一、涉及命令及知识分析

1.1解题思想探讨

拿到一个题,或者接手一项任务,我们首先应该怎么做?

PMP学习举例,办公室政治-方法很多,我们应该选择最优的方法

针对这个题,我想我们中间大部分应该都已经会了,而且我也在群里分享过我的思路。

1.2与创建用户相关的命令

要创建用户肯定离不开useradd命令,然后使用password命令设置密码,既然是批量创建肯定是非交互式执行,所以到这里我们应该想到使用—stdin参数。他们的常用格式一般如下:

useradd name

echo password |passwd –stdin name

我们可以通过分号将两条命令放在同一行同时执行,这样就可以一次性创建用户并为用户设置密码,当然有同学会问如果想要把密码记下来怎么办,其实也很简单,我们可以同时把pass字符串输出到一个文件,具体格式如下:

useradd name;echo password|passwd –stdin name;echopassword>>/tmp/passwd.txt

1.3批量执行相关思考

在linux里,我觉得要批量做一件事,主要有两个方向可以去思考,第一大家最容易想到的就是使用循环,第二就是在在命令里有两个可以批量创建和执行的命令一个seq、一个是{},seq是用来生成数字序列,{}即可以是数字序列,也可是字符序列,这样我们就可以利用这两个命令通过命令行拼接字符串的方式来实现,说到拼接字符串这里我们应该想到sed的后向引用,为什么要这样说呢。因为前面我们要通过seq或者{}生成和用户相关的序列,在后面想要使用前面字符串的内容最好的解决办法就是sed的后向引用。

1.4随机数和随机字符串

1、利用date命令生成随机数

[root@cmsweixin7151]# date +%s

1460971472//按秒生成

[root@cmsweixin7151]# date +%N

221539698//按纳秒生成,相当亿分之秒

[root@cmsweixin7151]# date +%s%N

1460971515409433433//两者的结合

[root@cms weixin7151]#

2、通过系统变量($RANDOM)获取随机数

[root@cmsweixin7151]# echo $RANDOM

8044

[root@cmsweixin7151]# echo $RANDOM

28351

[root@cmsweixin7151]# echo $RANDOM

20563

[root@cmsweixin7151]# echo $RANDOM

350

[root@cmsweixin7151]# echo $RANDOM

19317

[root@cmsweixin7151]# echo $RANDOM

6178

[root@cmsweixin7151]# echo $RANDOM

843

[root@cmsweixin7151]#

通过上面的我们可以看到最大的数字只有五位数,可能大家会想到要是我想生成8位的数怎么办呢?其实想一下就OK了。因为每一次生成的数字都不相同,那我们在这个基本上每一个数字给他加上10000000,那么就得到了一个随机的8位数了。

[root@cmsweixin7151]# echo $(($RANDOM+10000000))

10007221

[root@cmsweixin7151]#

3、通过md5sum命令生成随机字符串

md5sum在linux的最常用法就是使用他对一个文件生成一个字符串,如果对这个文件进行了修改,再次使用md5sum对文件生成一个字符串,这个时候比较两个字符来认识是否对此文件进行过修改。在这里我们可以对上面生成的字符串使用md5sum进行加密,然后生成一个字符串,由于上面的每一个数字是随机的,所以生成的字符串也是随机的。

[root@cmsweixin7151]# echo $(($RANDOM+10000000))|md5sum

7e8008ad11125bdca42b13624de19b99-

[root@cmsweixin7151]# echo $(($RANDOM+10000000))|md5sum

9e62014fd9eebdfe284758009e4e5087-

[root@cmsweixin7151]#

最后我们可以通过cut命令截取我们想要的字符串。

二、批量创建用户实践

2.1命令行拼接方式

批量生成十个用户,那我们就要在命令执行十次,所以我们就要生成十行命令,然后交给bash解释器执行。

[root@oldboy~]# echo stu{01..10}

stu01stu02 stu03 stu04 stu05 stu06 stu07 stu08 stu09 stu10

[root@oldboy~]# echo stu{01..10}|tr " " "\n"

stu01

stu02

stu03

stu04

stu05

stu06

stu07

stu08

stu09

stu10

[root@oldboy~]# echo stu{01..10}|xargs -n 1

stu01

stu02

stu03

stu04

stu05

stu06

stu07

stu08

stu09

stu10

[root@oldboy ~]#//接下来我们使用sed命令进行拼接。

[root@oldboy~]# echo stu{01..10}|xargs -n 1|sed -r 's#(.*)#\1#g'

stu01

stu02

stu03

stu04

stu05

stu06

stu07

stu08

stu09

stu10

[root@oldboy~]# echo stu{01..10}|xargs -n 1|sed -r 's#(.*)#useradd \1;#g'

useraddstu01;

useraddstu02;

useraddstu03;

useraddstu04;

useraddstu05;

useraddstu06;

useraddstu07;

useraddstu08;

useraddstu09;

useraddstu10;

这个时候我们如果将拼接的结果交给bash处理,结果就是创建了10个用户

[root@oldboy~]# echo stu{01..10}|xargs -n 1|sed -r 's#(.*)#useradd \1;#g'|bash

useradd:warning: the home directory already exists.

Notcopying any file from skel directory into it.

Creatingmailbox file: File exists

useradd:warning: the home directory already exists.

Notcopying any file from skel directory into it.

Creatingmailbox file: File exists

useradd:warning: the home directory already exists.

Notcopying any file from skel directory into it.

Creatingmailbox file: File exists

useradd:warning: the home directory already exists.

Notcopying any file from skel directory into it.

Creatingmailbox file: File exists

useradd:warning: the home directory already exists.

Notcopying any file from skel directory into it.

Creatingmailbox file: File exists

useradd:warning: the home directory already exists.

Notcopying any file from skel directory into it.

Creatingmailbox file: File exists

useradd:warning: the home directory already exists.

Notcopying any file from skel directory into it.

Creatingmailbox file: File exists

useradd:warning: the home directory already exists.

Notcopying any file from skel directory into it.

Creatingmailbox file: File exists

useradd:warning: the home directory already exists.

Notcopying any file from skel directory into it.

Creatingmailbox file: File exists

useradd:warning: the home directory already exists.

Notcopying any file from skel directory into it.

Creatingmailbox file: File exists

我们先删除刚才批量创建的用户,还是使用上面批量创建的方式。

[root@oldboy~]# echo stu{01..10}|xargs -n 1|sed -r 's#(.*)#userdel -r \1#g'|bash

userdel:/var/spool/mail/stu01 not owned by stu01, not removing

userdel:/home/stu01 not owned by stu01, not removing

userdel:/var/spool/mail/stu02 not owned by stu02, not removing

userdel:/home/stu02 not owned by stu02, not removing

userdel:/var/spool/mail/stu03 not owned by stu03, not removing

userdel:/home/stu03 not owned by stu03, not removing

userdel:/var/spool/mail/stu04 not owned by stu04, not removing

userdel:/home/stu04 not owned by stu04, not removing

userdel:/var/spool/mail/stu05 not owned by stu05, not removing

userdel:/home/stu05 not owned by stu05, not removing

userdel:/var/spool/mail/stu06 not owned by stu06, not removing

userdel:/home/stu06 not owned by stu06, not removing

userdel:/var/spool/mail/stu07 not owned by stu07, not removing

userdel:/home/stu07 not owned by stu07, not removing

userdel:/var/spool/mail/stu08 not owned by stu08, not removing

userdel:/home/stu08 not owned by stu08, not removing

userdel:/var/spool/mail/stu09 not owned by stu09, not removing

userdel:/home/stu09 not owned by stu09, not removing

userdel:/var/spool/mail/stu10 not owned by stu10, not removing

userdel:/home/stu10 not owned by stu10, not removing

接下我们继续拼接命令,在创建用户的同时给用户设备随机密码

[root@oldboy~]# echo stu{01..10}|xargs -n 1|sed -r 's#(.*)#useradd \1;echo $RANDOM|passwd\1 --stdin;#g'

useraddstu01;echo $RANDOM|passwd stu01 --stdin;

useraddstu02;echo $RANDOM|passwd stu02 --stdin;

useraddstu03;echo $RANDOM|passwd stu03 --stdin;

useraddstu04;echo $RANDOM|passwd stu04 --stdin;

useraddstu05;echo $RANDOM|passwd stu05 --stdin;

useraddstu06;echo $RANDOM|passwd stu06 --stdin;

useraddstu07;echo $RANDOM|passwd stu07 --stdin;

useraddstu08;echo $RANDOM|passwd stu08 --stdin;

useraddstu09;echo $RANDOM|passwd stu09 --stdin;

useraddstu10;echo $RANDOM|passwd stu10 --stdin;

将上面拼接好的字符串交给bash处理

[root@oldboy~]# echo stu{01..10}|xargs -n 1|sed -r 's#(.*)#useradd \1;echo $RANDOM|passwd\1 --stdin;#g'|bash

useradd:warning: the home directory already exists.

Notcopying any file from skel directory into it.

Creatingmailbox file: File exists

Changingpassword for user stu01.

passwd:all authentication tokens updated successfully.

useradd:warning: the home directory already exists.

Notcopying any file from skel directory into it.

Creatingmailbox file: File exists

Changingpassword for user stu02.

passwd:all authentication tokens updated successfully.

useradd:warning: the home directory already exists.

Notcopying any file from skel directory into it.

Creatingmailbox file: File exists

Changingpassword for user stu03.

passwd:all authentication tokens updated successfully.

useradd:warning: the home directory already exists.

Notcopying any file from skel directory into it.

Creatingmailbox file: File exists

Changingpassword for user stu04.

passwd:all authentication tokens updated successfully.

useradd:warning: the home directory already exists.

Notcopying any file from skel directory into it.

Creatingmailbox file: File exists

Changingpassword for user stu05.

passwd:all authentication tokens updated successfully.

useradd:warning: the home directory already exists.

Notcopying any file from skel directory into it.

Creatingmailbox file: File exists

Changingpassword for user stu06.

passwd:all authentication tokens updated successfully.

useradd:warning: the home directory already exists.

Notcopying any file from skel directory into it.

Creatingmailbox file: File exists

Changingpassword for user stu07.

passwd:all authentication tokens updated successfully.

useradd:warning: the home directory already exists.

Notcopying any file from skel directory into it.

Creatingmailbox file: File exists

Changingpassword for user stu08.

passwd:all authentication tokens updated successfully.

useradd:warning: the home directory already exists.

Notcopying any file from skel directory into it.

Creatingmailbox file: File exists

Changingpassword for user stu09.

passwd:all authentication tokens updated successfully.

useradd:warning: the home directory already exists.

Notcopying any file from skel directory into it.

Creatingmailbox file: File exists

Changingpassword for user stu10.

passwd:all authentication tokens updated successfully.

删除上面创建的用户

[root@oldboy~]# echo stu{01..10}|xargs -n 1|sed -r 's#(.*)#userdel \1#g'|bash

按上面的方法我们很快就会发现一个问题,我们创建的是随机密码,这样创建后连我们自己也不知道是什么密码了,所以我们要想办法把密码保存起来,那大家想一想我们有什么办法呢,我最初的想法是:

[root@oldboy~]# echo stu{01..10}|xargs -n 1|sed -r 's#(.*)#useradd \1;echo $RANDOM|passwd\1 --stdin; echo –e “\1\t $RANDOM”>>passwd.txt #g'|bash

大家想一下,这样可以吗?答案是否定的,因为后面保存的密码已经不是第一次生成的密码了,对吧。所以这时候我们需要使用一种方法提前生成密码并保存起来,然后在后面设置密码和保存密码的时候使用。

[root@oldboy~]# echo stu{01..10}|xargs -n 1|sed -r 's#(.*)#useradd \1;pass=$RANDOM;echo$pass|passwd \1 --stdin;echo-e"\1\t $pass">>pass.txt#g'|bash

useradd:warning: the home directory already exists.

Notcopying any file from skel directory into it.

Creatingmailbox file: File exists

Changingpassword for user stu01.

passwd:all authentication tokens updated successfully.

bash:line 1: echo-e: command not found

useradd:warning: the home directory already exists.

Notcopying any file from skel directory into it.

Creatingmailbox file: File exists

Changingpassword for user stu02.

passwd:all authentication tokens updated successfully.

bash:line 2: echo-e: command not found

useradd:warning: the home directory already exists.

Notcopying any file from skel directory into it.

Creatingmailbox file: File exists

Changingpassword for user stu03.

passwd:all authentication tokens updated successfully.

bash:line 3: echo-e: command not found

useradd:warning: the home directory already exists.

Notcopying any file from skel directory into it.

Creatingmailbox file: File exists

Changingpassword for user stu04.

passwd:all authentication tokens updated successfully.

bash:line 4: echo-e: command not found

useradd:warning: the home directory already exists.

Notcopying any file from skel directory into it.

Creatingmailbox file: File exists

Changingpassword for user stu05.

passwd:all authentication tokens updated successfully.

bash:line 5: echo-e: command not found

useradd:warning: the home directory already exists.

Notcopying any file from skel directory into it.

Creatingmailbox file: File exists

Changingpassword for user stu06.

passwd:all authentication tokens updated successfully.

bash:line 6: echo-e: command not found

useradd:warning: the home directory already exists.

Notcopying any file from skel directory into it.

Creatingmailbox file: File exists

Changingpassword for user stu07.

passwd:all authentication tokens updated successfully.

bash:line 7: echo-e: command not found

useradd:warning: the home directory already exists.

Notcopying any file from skel directory into it.

Creatingmailbox file: File exists

Changingpassword for user stu08.

passwd:all authentication tokens updated successfully.

bash:line 8: echo-e: command not found

useradd:warning: the home directory already exists.

Notcopying any file from skel directory into it.

Creatingmailbox file: File exists

Changingpassword for user stu09.

passwd:all authentication tokens updated successfully.

bash:line 9: echo-e: command not found

useradd:warning: the home directory already exists.

Notcopying any file from skel directory into it.

Creatingmailbox file: File exists

Changingpassword for user stu10.

passwd:all authentication tokens updated successfully.

bash:line 10: echo-e: command not found

[root@oldboy~]# echo stu{01..10}|xargs -n 1|sed -r 's#(.*)#useradd \1;pass=$RANDOM;echo$pass|passwd \1 --stdin;echo -e"\1\t $pass">>pass.txt#g'|bash

useradd:user 'stu01' already exists

Changingpassword for user stu01.

passwd:all authentication tokens updated successfully.

useradd:user 'stu02' already exists

Changingpassword for user stu02.

passwd:all authentication tokens updated successfully.

useradd:user 'stu03' already exists

Changingpassword for user stu03.

passwd:all authentication tokens updated successfully.

useradd:user 'stu04' already exists

Changingpassword for user stu04.

passwd:all authentication tokens updated successfully.

useradd:user 'stu05' already exists

Changingpassword for user stu05.

passwd:all authentication tokens updated successfully.

useradd:user 'stu06' already exists

Changingpassword for user stu06.

passwd:all authentication tokens updated successfully.

useradd:user 'stu07' already exists

Changingpassword for user stu07.

passwd:all authentication tokens updated successfully.

useradd:user 'stu08' already exists

Changingpassword for user stu08.

passwd:all authentication tokens updated successfully.

useradd:user 'stu09' already exists

Changingpassword for user stu09.

passwd:all authentication tokens updated successfully.

useradd:user 'stu10' already exists

Changingpassword for user stu10.

passwd:all authentication tokens updated successfully.

[root@oldboy~]# cat pass.txt

stu0113288

stu0224465

stu0323283

stu044573

stu0523015

stu0620841

stu0731821

stu0816954

stu093134

stu1028543

stu0130245

stu0230810

stu0324734

stu0416440

stu0517767

stu063100

stu076458

stu0815639

stu0914917

stu1011844

[root@oldboy~]#

我们可以上面讲过的其他方法替换生成随机密码的方法,也可以根据需要生成指定位数的密码,当然我们也可以使用seq生成序列。

2.2shell脚本循环

使用脚本创建用户,我觉得这个很简单一个循环就OK了,说简单就是把添加用户、设置密码,保存密码放在一个循环体里执行循环就OK。我个人认为这个要比命令行创建简单,我们来简单的演示一下,

[root@oldboy~]# for u in `echo {01..10}`;do useradd stu$u;pass=$RANDOM;echo $pass|passwdstu$u --stdin;echo -e "stu$u\t$pass";done

useradd:user 'stu01' already exists

Changingpassword for user stu01.

passwd:all authentication tokens updated successfully.

stu0129682

useradd:user 'stu02' already exists

Changingpassword for user stu02.

passwd:all authentication tokens updated successfully.

stu0211439

useradd:user 'stu03' already exists

Changingpassword for user stu03.

passwd:all authentication tokens updated successfully.

stu0317076

useradd:user 'stu04' already exists

Changingpassword for user stu04.

passwd:all authentication tokens updated successfully.

stu0423187

useradd:user 'stu05' already exists

Changingpassword for user stu05.

passwd:all authentication tokens updated successfully.

stu05427

useradd:user 'stu06' already exists

Changingpassword for user stu06.

passwd:all authentication tokens updated successfully.

stu069757

useradd:user 'stu07' already exists

Changingpassword for user stu07.

passwd:all authentication tokens updated successfully.

stu0716146

useradd:user 'stu08' already exists

Changingpassword for user stu08.

passwd:all authentication tokens updated successfully.

stu0822999

useradd:user 'stu09' already exists

Changingpassword for user stu09.

passwd:all authentication tokens updated successfully.

stu0913010

useradd:user 'stu10' already exists

Changingpassword for user stu10.

passwd:all authentication tokens updated successfully.

stu103806

当然你可以将生成的用户名和密码保存到一个文件里

[root@oldboy~]# for u in `echo {01..10}`;do useradd stu$u;pass=$RANDOM;echo $pass|passwdstu$u --stdin;echo -e "stu$u\t$pass">>pass.txt;done

useradd:user 'stu01' already exists

Changingpassword for user stu01.

passwd:all authentication tokens updated successfully.

useradd:user 'stu02' already exists

Changingpassword for user stu02.

passwd:all authentication tokens updated successfully.

useradd:user 'stu03' already exists

Changingpassword for user stu03.

passwd:all authentication tokens updated successfully.

useradd:user 'stu04' already exists

Changingpassword for user stu04.

passwd:all authentication tokens updated successfully.

useradd:user 'stu05' already exists

Changingpassword for user stu05.

passwd:all authentication tokens updated successfully.

useradd:user 'stu06' already exists

Changingpassword for user stu06.

passwd:all authentication tokens updated successfully.

useradd:user 'stu07' already exists

Changingpassword for user stu07.

passwd:all authentication tokens updated successfully.

useradd:user 'stu08' already exists

Changingpassword for user stu08.

passwd:all authentication tokens updated successfully.

useradd:user 'stu09' already exists

Changingpassword for user stu09.

passwd:all authentication tokens updated successfully.

useradd:user 'stu10' already exists

Changingpassword for user stu10.

passwd:all authentication tokens updated successfully.

三、总结及思考

此题是我们前面所学命令与知识的一个综合运用,我们回顾一下,主要涉及创建用户、非交互式设置密码、生成序列,管道,sed、date、生成随机数,md5sum、cut、echo –e等很多命令的使用,希望大家可以综合使用各种方式多试试。

最后我想提出来一个题,大家可以去试一试,就是批量更改文件名,比如我想把/tmp目录下所有以.txt结尾的文件改名为以.txt结尾,要求还是使用命令行拼接的方式处理。我提示一下,我们可以使用find命令查找,然后使用ls –l列表,再通过awk取到文件名,然后使用sed拼接命令,当然还很多,这只是我想到的一种。

四、批量改名

4.1使用脚本循环方式

[root@oldboy oldboy]# cat file.list

stu_10299_1_finished.jpg

stu_10299_2_finished.jpg

stu_10299_3_finished.jpg

stu_10299_4_finished.jpg

stu_10299_5_finished.jpg

[root@oldboyoldboy]# touch `cat file.list`

[root@oldboyoldboy]# ls

file.liststu_10299_2_finished.jpgstu_10299_4_finished.jpg

stu_10299_1_finished.jpgstu_10299_3_finished.jpgstu_10299_5_finished.jpg

[root@oldboyoldboy]# sh rename.sh

[root@oldboyoldboy]# ls

file.listrename.shstu_10299_1.jpgstu_10299_2.jpgstu_10299_3.jpgstu_10299_4.jpgstu_10299_5.jpg

[root@oldboyoldboy]# cat rename.sh

#!/bin/sh

forf in `ls *.jpg`

do

mv $f `echo $f|sed 's#_finished##g'`

done

[root@oldboyoldboy]#

思想是使用命令mv oldnae newname

4.2使用拼接字符串方式

使用awk命令拼接

[root@oldboyoldboy]# touch `cat file.list`

[root@oldboyoldboy]# ls

file.liststu_10299_1_finished.jpgstu_10299_3_finished.jpgstu_10299_5_finished.jpg

rename.shstu_10299_2_finished.jpgstu_10299_4_finished.jpg

[root@oldboyoldboy]# ls|awk -F "_finished" '{print "mv " $0}'

mvfile.list

mvrename.sh

mvstu_10299_1_finished.jpg

mvstu_10299_2_finished.jpg

mvstu_10299_3_finished.jpg

mvstu_10299_4_finished.jpg

mvstu_10299_5_finished.jpg

[root@oldboyoldboy]# ls *.jpg|awk -F "_finished" ' {print "mv " $0}'

mvstu_10299_1_finished.jpg

mvstu_10299_2_finished.jpg

mvstu_10299_3_finished.jpg

mvstu_10299_4_finished.jpg

mvstu_10299_5_finished.jpg

[root@oldboyoldboy]# ls *.jpg|awk -F "_finished" ' {print "mv " $0$1$2}'

mvstu_10299_1_finished.jpgstu_10299_1.jpg

mvstu_10299_2_finished.jpgstu_10299_2.jpg

mvstu_10299_3_finished.jpgstu_10299_3.jpg

mvstu_10299_4_finished.jpgstu_10299_4.jpg

mvstu_10299_5_finished.jpgstu_10299_5.jpg

[root@oldboyoldboy]# ls *.jpg|awk -F "_finished" ' {print "mv " $0" "$1$2}'

mvstu_10299_1_finished.jpg stu_10299_1.jpg

mvstu_10299_2_finished.jpg stu_10299_2.jpg

mvstu_10299_3_finished.jpg stu_10299_3.jpg

mvstu_10299_4_finished.jpg stu_10299_4.jpg

mvstu_10299_5_finished.jpg stu_10299_5.jpg

[root@oldboyoldboy]# ls *.jpg|awk -F "_finished" ' {print "mv " $0" "$1$2}'|bash

[root@oldboyoldboy]# ls

file.listrename.shstu_10299_1.jpgstu_10299_2.jpgstu_10299_3.jpgstu_10299_4.jpgstu_10299_5.jpg

[root@oldboyoldboy]#

使用sed命令

[root@oldboyoldboy]# ls *.jpg

stu_10299_1_finished.jpgstu_10299_3_finished.jpgstu_10299_5_finished.jpg

stu_10299_2_finished.jpgstu_10299_4_finished.jpg

[root@oldboyoldboy]# ls *.jpg|xargs -n1

stu_10299_1_finished.jpg

stu_10299_2_finished.jpg

stu_10299_3_finished.jpg

stu_10299_4_finished.jpg

stu_10299_5_finished.jpg

[root@oldboyoldboy]# ls *.jpg|xargs -n1|sed -r 's#(^.*)_finished(.*)#mv \1\2#g'

mvstu_10299_1.jpg

mvstu_10299_2.jpg

mvstu_10299_3.jpg

mvstu_10299_4.jpg

mvstu_10299_5.jpg

[root@oldboyoldboy]# ls *.jpg|xargs -n1|sed -r 's#(^.*)_finished(.*)#mv & \1\2#g'

mvstu_10299_1_finished.jpg stu_10299_1.jpg

mvstu_10299_2_finished.jpg stu_10299_2.jpg

mvstu_10299_3_finished.jpg stu_10299_3.jpg

mvstu_10299_4_finished.jpg stu_10299_4.jpg

mvstu_10299_5_finished.jpg stu_10299_5.jpg

[root@oldboyoldboy]# ls *.jpg|xargs -n1|sed -r 's#(^.*)_finished(.*)#mv & \1\2#g'|bash

[root@oldboyoldboy]# ls

file.listrename.shstu_10299_1.jpgstu_10299_2.jpgstu_10299_3.jpgstu_10299_4.jpgstu_10299_5.jpg

[root@oldboyoldboy]#

4.3使用rename命令

[root@oldboyoldboy]# ls

file.liststu_10299_1_finished.jpgstu_10299_3_finished.jpgstu_10299_5_finished.jpg

rename.shstu_10299_2_finished.jpgstu_10299_4_finished.jpg

[root@oldboy oldboy]# rename"_finished" "" *.jpg

[root@oldboyoldboy]# ls

file.listrename.shstu_10299_1.jpgstu_10299_2.jpgstu_10299_3.jpgstu_10299_4.jpgstu_10299_5.jpg

[root@oldboyoldboy]#

思想就是专业的人做专业的事

相关文章

网友评论

    本文标题:Linux批量创建用户讲解

    本文链接:https://www.haomeiwen.com/subject/afngzttx.html