浏览模式: 标准 | 列表 2013年01月29日的文章

Linux下shell支持中文显示的方法

对当前环境临时生效:export LANG=zh_CN.GB18030

永久写入配置文件:vi /etc/sysconfig/i18n

  • #LANG="en_US.UTF-8"
  • LANG="zh_CN.GB18030"
  • SYSFONT="latarcyrheb-sun16"

Linux下shell取得字符串行数与指定字符串长度

有某个文本文件is36.txt,需要取得字符串行数指定字符串长度

linuxshell取得字符串行数:

  • cat is36.txt | wc -l

Linux下shell取得指定字符串长度(默认第一行):

  • cat is36.txt | wc -L

Linux下shell取得指定字符串长度(2p即第二行):

  • sed -n '2p' is36.txt | wc -L

Tags: linux, shell, 字符串行数, 指定字符串长度