Enterprise Shell interview Case (top)

Source: Internet
Author: User

  • Mass production of random character filenames

    Requirement: Use the For loop to create 10 batches of HTML in the/oldboy directory. Each of these files needs to contain 10 random lowercase letters plus a fixed string of Oldboy.

  • #!/bin/bash[!-d/oldboy] && mkdir/oldboycd/oldboyfor (i=0;i<10;i++) do aa= "' Echo $RANDOM | md5sum | Cut-c 1-11 ' "Touch" $AA "_oldboy.htmldone~

    2. Batch Renaming

    Change all of the above Oldboy to oldgirl (preferably with for) and change the extension to uppercase

    #!/bin/bashcd/oldboyfor i in ' ls/oldboy ' do rename "Oldboy" "Oldgirl"/oldboy/$i rename "html" "HTML"/oldboy/$idone ~

    3. Scan the surviving hosts in the network:

    #!/bin/bashfor i in ' seq ten ' do ip=192.168.116. $i ping-w 5-c 2 $ip >/dev/null aa=$? If [$?-ne 0] Then echo ' This $ip are bad ... "else echo" This $ip is good ... "fidone~


    Enterprise Shell interview Case (top)

    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.