Linux shell statement-based program

Source: Internet
Author: User

Shell code #! /Bin/bash for a in $ @ do case $ a in file = *) file = "$ (echo $ a | sed's /. * = //; s/% sp % // G') "; list) mode = list; find = *) mode = find var = "$ (echo $ a | sed's /. * = //; s/, // G') "; add = *) mode = add var =" $ (echo $ a | sed's /. * = // ') "; del = *) mode = del var =" $ (echo $ a | sed's /. * = //; s/, // G') "; help) cat <EOF Word Table program usage: voct file = [list | help | add = | del = | find =] file = All spaces in the file name should be replaced by % sp %, the file name cannot contain % sp % list to list all projects in the file. help shows this help add = add entry 1 [, add entry 2, add entry 3...] del = Delete entry 1 [, delete entry 2, delete entry 3...] find = search for Entry 1 [, search for entry 2, search for entry 3...] an entry and an entry are separated by commas (,) to start with a row. For example, del = abc can delete an entry. If you want to delete an entry from abc and abcd, use find to find the entry first, then, use the independent start of the entry to be deleted (not overlapped with other entries) to delete the equal sign and no equal sign can be added. We recommend that you use "--" instead of EOF exit esac case $ mode in list) cat "$ file"; find) for var3 in $ var do cat "$ file" | grep -- color = never $ var3 done; del) for var0 in $ var do sed-I "/^ $ var0/d" "$ file" done; add) touch $ file have = 1 [$ have = 1] & var2 = "$ (echo $ var | sed's/% sp % // g; s /,, /# enter #/G ') "& echo $ var2>" $ file "& sed-I's/# enter #/\ n/G'" $ file "esac done

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.