Linux批量創建用戶講解

一、涉及命令及知識分析

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]#

思想就是專業的人做專業的事

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容