Interesting O & M programming questions

Source: Internet
Author: User

Interesting O & M programming questions

Use the for loop to create 10 html files in batch in the/oldboy directory with 10 random lowercase letters and a fixed string oldboy. The name is as follows:

 

  coaolvajcq_oldboy.html qnvuxvicni_oldboy.html vioesjmcbu_oldboy.html gmkhrancxh_oldboy.html tmdjormaxr_oldboy.html wzewnojiwe_oldboy.html jdxexendbe_oldboy.html ugaywanjlm_oldboy.html xzzruhdzda_oldboy.html qcawgsrtkp_oldboy.html vfrphtqjpc_oldboy.html

 

 

#!/bin/bashletter=(`echo {a..z}`)function create_filename(){filename=`for i in $(seq 10)doecho -n ${letter[$(($RANDOM%24))]}done`_oldboy.html}for i in $(seq 10)docreate_filenametouch $filenamedone

Replace all oldboys in the above two file names with oldgirl (implemented using the for loop), and change html to uppercase.

 

 

#!/bin/bashfilelist=`ls | grep ".html$"`for i in $filelistdomv $i ${i%%_*}_oldgirl.HTMLdone

 

 

 

#!/bin/bashfilelist=`ls | grep ".html$"`for i in $filelistdonewfile=`echo $i | awk -F'_' '{print $1"_oldgirl.HTML"}'`mv $i $newfiledone


 

Create 10 SYSTEM account oldboy01-oldboy10 in batches and set the password (the password is a random 8-Bit String ).

 

#!/bin/bashfor i in `seq 10`doif [[ $i -lt 10 ]];thenuseradd oldboy0$i && echo `cat /dev/urandom | sed 's/[^a-zA-Z0-9]//g' | strings -n 8 | head -n 1` | passwd oldboy0$i --stdinelse useradd oldboy$i && echo `cat /dev/urandom | sed 's/[^a-zA-Z0-9]//g' | strings -n 8 | head -n 1` | passwd oldboy$i --stdinfidone


Write a script to determine the IP addresses of online users in the 10.0.0.0/24 network (there are many methods)

 

Single Process

 

#!/bin/bashfor i in `seq 2 255`doping 10.0.0.$i -c 1 1>/dev/null && echo 10.0.0.$i: live || echo 10.0.0.$i: deaddone

Multi-Process

 

 

#!/bin/bashtmp_fifofile="/tmp/$$.fifo"mkfifo $tmp_fifofileexec 6<>$tmp_fifofilerm -rf $tmp_fifofilethread=254for ((i=0;i<$thread;i++))doecho ""done >&6for ((i=1;i<254;i++))doread -u6        {        ping 10.0.0.$i -c 1 1>/dev/null && echo 10.0.0.$i: live || echo 10.0.0.$i: dead        echo "">&6        } &donewaitexec 6>&-exit 0

 

Bash for loop print the words with no more than 6 letters in the following sentence (Kunlun wanwei interview ).
I am oldboy teacher welcome to oldboy training class.

 

#!/bin/bashcontent="I am oldboy teacher welcome to oldboy training class."new_content=`echo $content | sed 's/\.//'`echo $new_contentarg=(`echo $new_content`)for i in ${arg[@]}doif [[ ${#i} -le 6 ]];thenecho $ifidone

 

It is known that the following string is the result after the RANDOM number variable md5sum | cut-c 1-8 is intercepted by RANDOM. Please crack the number of the RANDOM corresponding to the md5sum corresponding to these strings?

21029299

00205d1c

A3da1677

1f6d12dd

890684b

 

 

 

#!/bin/bashdeclare -a arrayfor i in $(seq 0 32767)doarray[$i]=`echo $i | md5sum | cut -c 1-8`donekeys=([0]=21029299 [1]=00205d1c [2]=a3da1677 [3]=1f6d12dd [4]=890684b)echo "number ------- md5sum"for key in ${keys[@]}dofor i in `seq 0 32767`doif [[ "${array[i]}" == "$key" ]];thenecho $i ------- $keyfidonedone

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.