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

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

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 229,517評論 6 539
  • 序言:濱河連續發生了三起死亡事件,死亡現場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機,發現死者居然都...
    沈念sama閱讀 99,087評論 3 423
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 177,521評論 0 382
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 63,493評論 1 316
  • 正文 為了忘掉前任,我火速辦了婚禮,結果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當我...
    茶點故事閱讀 72,207評論 6 410
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發上,一...
    開封第一講書人閱讀 55,603評論 1 325
  • 那天,我揣著相機與錄音,去河邊找鬼。 笑死,一個胖子當著我的面吹牛,可吹牛的內容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 43,624評論 3 444
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 42,813評論 0 289
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后,有當地人在樹林里發現了一具尸體,經...
    沈念sama閱讀 49,364評論 1 335
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 41,110評論 3 356
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發現自己被綠了。 大學時的朋友給我發了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 43,305評論 1 371
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 38,874評論 5 362
  • 正文 年R本政府宣布,位于F島的核電站,受9級特大地震影響,放射性物質發生泄漏。R本人自食惡果不足惜,卻給世界環境...
    茶點故事閱讀 44,532評論 3 348
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 34,953評論 0 28
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 36,209評論 1 291
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個月前我還...
    沈念sama閱讀 52,033評論 3 396
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 48,268評論 2 375

推薦閱讀更多精彩內容