2017 the latest enterprise face Test shell (i)

Source: Internet
Author: User

2017 the latest enterprise face Test shell (i)


**********************************************

Enterprise Shell face question 1: Batch generate random character file name case *

**********************************************

Use the For loop to bulk create 10 HTML files in the/oldboy directory, where each file needs to contain 10 random lowercase characters plus a fixed string oldboy, with the following name examples:

[Email protected] c19]# Ls/oldboy

apquvdpqbk_oldboy.html mpyogpsmwj_oldboy.html txynzwofgg_oldboy.html

bmqiwhfpgv_oldboy.html mtrzobsprf_oldboy.html vjxmlflawa_oldboy.html

Jhjdcjnjxc_oldboy.html qeztkkmewn_oldboy.html

Jpvirsnjld_oldboy.html ruscyxwxai_oldboy.html

Answer:

The script reads as follows: (For loop implementation script)

#!/bin/bash

#date =2017-8-3

Cd/oldboy

For ((i=0;i<10;i++))

Do

R= ' head-c 500/dev/urandom|tr-dc [a-z]|head-c 10|sed-r ' s#[^a-z] #m #g '

Touch "$r" _oldboy.html

Done

Description

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M02/9D/A6/wKioL1mDM3aQV89rAAAI-_RBAZ0455.png "title=" SS. PNG "alt=" Wkiol1mdm3aqv89raaai-_rbaz0455.png "/>

The script execution results are as follows:

[email protected] oldboy]# LL

Total Dosage 8

-rw-r--r--1 root root 0 August 3 13:35 defozmpplm_oldboy.html

-rw-r--r--1 root root 175 August 3 13:35 for.sh

-rw-r--r--1 root root 0 August 3 13:35 fpwxukgqho_oldboy.html

-rw-r--r--1 root root 0 August 3 13:35 gwtwtmdwaf_oldboy.html

-rw-r--r--1 root root 0 August 3 13:35 htttummyjh_oldboy.html

-rw-r--r--1 root root 0 August 3 13:35 myqmgyixuj_oldboy.html

-rw-r--r--1 root root 0 August 3 13:35 rmsyxakjbx_oldboy.html

-rw-r--r--1 root root 0 August 3 13:35 sxarorojil_oldboy.html

-rw-r--r--1 root root 0 August 3 13:35 wfqaymdmxc_oldboy.html

-rw-r--r--1 root root 184 August 3 13:32 while.sh

-rw-r--r--1 root root 0 August 3 13:35 yvgviwswze_oldboy.html

-rw-r--r--1 root root 0 August 3 13:35 zhikoyxipv_oldboy.html


The script reads as follows: (While loop implementation script)

#!/bin/bash

#date =2017-8-3

Cd/oldboy

I=0

while ((I<10))

Do

R= ' head-c 500/dev/urandom|tr-dc [a-z]|head-c 10|sed-r ' s#[^a-z] #m #g '

Touch "$r" _oldboy.html

((i++))

Done

Description

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/9D/A7/wKiom1mDM5bxs7blAAAI-_RBAZ0752.png "title=" SS. PNG "alt=" Wkiom1mdm5bxs7blaaai-_rbaz0752.png "/>

The script execution results are as follows:

[email protected] oldboy]# LL

Total Dosage 4

-rw-r--r--1 root root 0 August 3 13:28 atncjmfwtd_oldboy.html

-rw-r--r--1 root root 0 August 3 13:28 bmbhdhvqmb_oldboy.html

-rw-r--r--1 root root 0 August 3 13:28 bmuqvcehgc_oldboy.html

-rw-r--r--1 root root 0 August 3 13:28 irfrxjjmny_oldboy.html

-rw-r--r--1 root root 0 August 3 13:28 mvprsmwvah_oldboy.html

-rw-r--r--1 root root 0 August 3 13:28 nxyfjkvekl_oldboy.html

-rw-r--r--1 root root 0 August 3 13:28 omqyxuykgq_oldboy.html

-rw-r--r--1 root root 0 August 3 13:28 smkxwfjepd_oldboy.html

-rw-r--r--1 root root 184 August 3 13:28 while.sh

-rw-r--r--1 root root 0 August 3 13:28 wkwmkktdcn_oldboy.html

-rw-r--r--1 root root 0 August 3 13:28 xtznpcuxem_oldboy.html

************************************

Enterprise Shell face question 2: Batch renaming special case *

************************************

The Oldboy string in the result file name in question 1 above will be changed to oldgirl (preferably with a For loop), and the extension HTML will all be changed to uppercase.

Answer:

The For Loop implementation script is as follows:

#!/bin/bash

#date =2017-8-3

Cd/oldboy

For i in ' Ls|grep. *html '

Do

MV $i ' echo $i |sed-r ' s# (. *) _oldboy.html#\1_oldgirl. html# "

Done

Description

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M00/9D/A6/wKioL1mDNKjz8XvwAAAENqNwI6o500.png "title=" SS. PNG "alt=" Wkiol1mdnkjz8xvwaaaenqnwi6o500.png "/>

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M02/9D/A6/wKioL1mDM_2R8tN-AAAKawvr4CQ952.png "title=" SS. PNG "alt=" Wkiol1mdm_2r8tn-aaakawvr4cq952.png "/>

The script execution results are as follows:

[Email protected] oldboy]# sh for2.sh

Ahqrvgmewi_oldgirl. Html

Cekphjpxmf_oldgirl. Html

Fodvkohejd_oldgirl. Html

Llymsvwhim_oldgirl. Html

Mejlzbfmna_oldgirl. Html

Mxqrnbgmnt_oldgirl. Html

Pkviyuhrum_oldgirl. Html

Shmmlxzkdu_oldgirl. Html

Wmgokfirna_oldgirl. Html

Wmmknomcmy_oldgirl. Html

Other methods reference:http://wutengfei.blog.51cto.com/10942117/1951146


********************************************

Enterprise Shell face question 3: Batch Create special requirements user Stories *

********************************************


Batch Create 10 System account OLDBOY01-OLDBOY10 and set the password (password is random number, require characters and numbers and so on mixed).

Without a For loop implementation idea: http://user.qzone.qq.com/49000448/blog/1422183723

Answer:

#!/bin/bash

#date =2018-8-3

For i in ' seq-w 1 10 '

Do

Useradd oldboy$i-m

echo "' OpenSSL rand-base64 8 '" |PASSWD--stdin oldboy$i

Done

Description

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M01/9D/A7/wKiom1mDNOLAsbmLAAADngr54ks036.png "title=" SS. PNG "alt=" Wkiom1mdnolasbmlaaadngr54ks036.png "/>

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/9D/A7/wKiom1mDNEuQYuZoAAAG_wynBtY537.png "title=" SS. PNG "alt=" Wkiom1mdneuqyuzoaaag_wynbty537.png "/>

This article is from the "Hand of the Paladin Control" blog, please make sure to keep this source http://wutengfei.blog.51cto.com/10942117/1953452

2017 the latest enterprise face Test shell (i)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.