Realize:
Step 1: Add the following code in the corresponding environment variable configuration file (no ~/.BASHRC,/etc/profile, etc in these files)
Here we add to the ~/.BASHRC file
# jianbing.org on dnsfunction J {Dig "$*.jianbing.org" +short txt | perl-pe ' s/\\ (\d{1,3})/chr $1/eg; s/(^ "|" $)//g '}
Step 2: Reopen a shell, and at the command line type J + the word that needs to be translated. Such as:
[Email protected] ~]# J cat[kt]n. cat [[email protected] ~]# J Dog[dg]n. Dogs, dogs, dog-like animals, despicable people, villains, villains Vt. Tracking, trailing
Look at the code is also relatively simple, is to write a shell function, After stitching the words or phrases received by the function and jianbing.org, the DNS query is made by dig, the short information is returned, the regular matching substitution is passed to Perl through the pipeline, and finally formatted by the shell of Linux itself.
This article is from the "Static Like Night Wind" blog, please make sure to keep this source http://siliotto.blog.51cto.com/8887165/1598177
Open the Linux command line English-Chinese dictionary