shell编程
钢都百炼生
努力奋斗的青年
展开
-
文件循环拷贝
<br />#!/bin/sh<br /># vim: set sw=4 ts=4 et:<br /><br />ver="0.1"<br />help()<br />{<br /> cat << HELP<br /> rotatefile -- rotate the file name<br /> USAGE: rotatefile [-h] filename<br /> OPTIONS: -h help text<br /> EXAMPLE: rotatefile out<br />原创 2011-02-27 16:05:00 · 516 阅读 · 0 评论 -
统计网络流量
分享一个脚本统计网络流量:#!/bin/bash# Almost everything of this is shamelessly copied from# http://www.lugmen.org.ar/~conan/tmp/wmii/statuswhile true; do RX0=`/bin/grep eth0 /proc/net/dev | tr ':' ' '原创 2013-03-13 17:03:27 · 889 阅读 · 0 评论 -
Debian 字符编码转换
UTF-8 conversionIf upstream documents are encoded in old encoding schemes, converting them to UTF-8 is a good idea. Use iconv(1) to convert encodings of plain text files.iconv -f latin转载 2013-03-14 15:45:22 · 1011 阅读 · 0 评论 -
Linux终端编程
#include #include int tcgetattr(int fd, struct termios *termios_p); int tcsetattr(int fd, int optional_actions, const struct termios *termios_p); v原创 2012-07-29 17:53:56 · 702 阅读 · 0 评论 -
Bash启动
在Bash启动时会加载配置文件。login shell:启动加载文件有:/etc/profile~/.bash_profile~/.bash_login~/.profile程序将依次执行这些文件,如果你加上选项"--noprofile"启动程序,bash将不会解析上述文件当Bash推出时,会检查~/.bash_logout。non-login shel原创 2012-02-27 14:25:49 · 1092 阅读 · 0 评论 -
shell脚本与C语言之间的关系
#if 0#!/bin/bashgcc $0./a.outexit#endif#include int main(int argc,char **argv){ printf("Hello,world\n"); return 0;}原创 2011-12-20 14:19:54 · 1337 阅读 · 0 评论 -
grep 命令使用总结
文本内容的过滤查询是测试和开发中常用到的。 先举一个小例子:cat test.txthello,worldni hao zhong guo.使用如下命令可以查询包含有特定字符串的行grep hao test.txt包含有hao的行被检索出来。grep -v hao test.txt如果是加上一个-v 选项那不包含hao 的所有行都会被显示原创 2011-12-13 11:20:44 · 449 阅读 · 0 评论 -
史上最牛的 shell命令
sudo !!以管理员身份,重新执行上一条命令原创 2011-03-08 14:09:00 · 741 阅读 · 0 评论 -
b2d 二进制转换十进制
<br />#!/bin/sh# vim: set sw=4 ts=4 et:help(){ cat << HELP b2d -- convert binary to decimal USAGE: b2d [-h] binarynum OPTIONS: -h help text EXAMPLE: b2d 111010will return 58HELP exit 0} error(){ # print an er原创 2011-02-27 15:57:00 · 625 阅读 · 0 评论 -
内存消耗测试
今天在阅读邮件时发现某位大神给出了两个可以快速消耗内存的方法。Here's 2 commands you can run on a test system that will consume a significant amount of memory without installing any additional software.host:~ # dd if=/dev/zero of=/d原创 2016-01-21 10:47:25 · 831 阅读 · 0 评论