Awk uses one example: get ASCII visible characters

Source: Internet
Author: User

To make a requirement, the password settings for the visible special characters are supported. First, you need to get all the visible special characters. Search the online ASCII character table and copy it to the text file Vschars.txt:

00000nul1004064@01011soh1014165a02022stx1024266b03033etx1034367c04044eot1044468d05055enq1054569e06066ack1064670f07077bel1 074771g10088bs1104872h11099ht1114973i120a10nl1124a74j130b11vt1134b75k140c12ff1144c76l150d13er1154d77m160e14so1164e78n170f 15si1174f79o201016dle1205080p211117dc11215181q221218dc21225282r231319dc31235383s241420dc41245484t251521nak1255585u261622s yn1265686v271723etb1275787w301824can1305888x311925em1315989y321a26sub1325a90z331b27esc1335b91[ 341c28fs1345c92351d29gs1355d93]361e30re1365e94^371f31us1375f95_402032sp1406096 ' 412133!1416197a422234 ' 1426298b432335#1436399c442436$14464100d452537%14565101e462638&14666102f472739 ' 14767103g502840 ( 15068104h512941) 15169105I522A42*1526A106J532B43+1536B107K542C44, 1546c108l552d45-1556d109m562e46.1566e110n572f47/ 1576f111o603048016070112p613149116171113q623250216272114r633351316373115s643452416474116t653553516575117u663654616676118v 673755716777119w703856817078120x713957917179121y723a58:1727a122z733b59;1737b123{743c60<1747c124|753d61= 1757d125}763e62>1767e126~773f63?1777f127del 

Now you need to extract all the visible special characters from the text file, including, of course, common uppercase and lowercase letters and numbers. You can use the following command:

awk  ' begin{ofs= "\ n"}{print $4, $8} ' Sort awk ' begin{ors= ""}{if (Length ($) ==1) {print $}} ' ' -!" #$%& () *,./:; [Email protected] [\]^_`{|} ~+<=>0123456789aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz

explain:

1. First, you need to output the required characters. Awk uses $4, $8 can get the required columns, the default white space character splits, the output delimiter OFS select line break, to ensure that each line one;

2. Then make a sort, so that letters, numbers, special characters are displayed separately;

3. Discover that the visible character is a character that can be filtered using the record length: if (length ($) ==1) {print $}. Record delimiter ORS Select an empty string to ensure that all visible characters appear next to each other. It is easy to write regular expressions directly.

The regular expression that supports ASCII-visible characters (including spaces) is: ^[a-za-z0-9 '!\ "#$%& () *,./:;[ Email protected]^_ ' \\[\\]{|} ~+<=>\\-]{m,n}$

Awk uses one example: get ASCII visible characters

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.