未加星标

Linux Tip Of The Day - recode

字体大小 | |
[系统(linux) 所属分类 系统(linux) | 发布者 店小二05 | 时间 2017 | 作者 红领巾 ] 0人收藏点击收藏

As I discussedyesterday, I’m currently talking about the dependencies in John Graham Cummings, hncomments bash script. At the end of this I’m hoping that I have all the pieces that I can actually run this myself.

The recode tool, a utility I had never even heard of, converts files between various character sets. Given all the troubles I’ve had over the years with crawling the different app stores and encodings, I’m glad to learn about this.

If you’re on linux then you can install recode with:

sudo apt-get install recode

If you’re on OSX then install recode with:

brew install recode

Use recode help to get assistance (this is only a subset of the help):

recode --help Free `recode' converts files between various character sets and surfaces. Usage: recode [OPTION]... [ [CHARSET] | REQUEST [FILE]... ] If a long option shows an argument as mandatory, then it is mandatory for the equivalent short option also. Similarly for optional arguments. Listings: -l, --list[=FORMAT] list one or all known charsets and aliases -k, --known=PAIRS restrict charsets according to known PAIRS list -h, --header[=[LN/]NAME] write table NAME on stdout using LN, then exit -F, --freeze-tables write out a C module holding all tables -T, --find-subsets report all charsets being subset of others -C, --copyright display Copyright and copying conditions --help display this help and exit --version output version information and exit Operation modes: -v, --verbose explain sequence of steps and report progress -q, --quiet, --silent inhibit messages about irreversible recodings -f, --force force recodings even when not reversible -t, --touch touch the recoded files after replacement -i, --sequence=files use intermediate files for sequencing passes --sequence=memory use memory buffers for sequencing passes -p, --sequence=pipe use pipe machinery for sequencing passes Fine tuning: -s, --strict use strict mappings, even loose characters -d, --diacritics convert only diacritics or alike for HTML/LaTeX -S, --source[=LN] limit recoding to strings and comments as for LN -c, --colons use colons instead of double quotes for diaeresis -g, --graphics approximate IBMPC rulers by ASCII graphics -x, --ignore=CHARSET ignore CHARSET while choosing a recoding path

If we go back to the source on hncomments then we can see how recode fits in:

jq -r ‘.hits .[] .author + “\nhttps://news.ycombinator.com/item?id=” + .objectID + “\n\n” + .comment_text + “\n\n―\n\n”’ <(echo $j) sed -e ‘s/<[^>]*>/ /g;’ recode -f html..ascii mail -s “Latest $q HN comments” $e

Here recode is taking the output from sed and converting it from html character encoding to ASCII.

本文系统(linux)相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统

主题: LinuxHTMLTIIBMOPT
分页:12
转载请注明
本文标题:Linux Tip Of The Day - recode
本站链接:http://www.codesec.net/view/530749.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(linux) | 评论(0) | 阅读(42)