<?xml version="1.0" encoding="gbk"?>
<rss version="2.0">
  <channel>
    <title>曲径通幽论坛 - Shell Examples</title>
    <link>http://www.groad.net/bbs/forum.php?mod=forumdisplay&amp;fid=58</link>
    <description>Latest 20 threads of Shell Examples</description>
    <copyright>Copyright(C) 曲径通幽论坛</copyright>
    <generator>Discuz! Board by Comsenz Inc.</generator>
    <lastBuildDate>Sun, 12 Jul 2026 12:31:40 +0000</lastBuildDate>
    <ttl>60</ttl>
    <image>
      <url>http://www.groad.net/bbs/static/image/common/logo_88_31.gif</url>
      <title>曲径通幽论坛</title>
      <link>http://www.groad.net/bbs/</link>
    </image>
    <item>
      <title>使用 curl 来管理百度网盘</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=8115</link>
      <description><![CDATA[百度网盘是开放 API 的，获取这些 API 首先需要加入百度开发者，其网址为：http://developer.baidu.com/dev#/create
 
接着，创建任意一个应用，其目的是为了获取 API Key 并开通其权限，如下图所示：

如右侧红色方框中，状态为开启的表示可以使用该 API 服务权限 ...]]></description>
      <category>Shell Examples</category>
      <author>beyes</author>
      <pubDate>Mon, 04 Nov 2013 12:24:17 +0000</pubDate>
    </item>
    <item>
      <title>统计重复行</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=7582</link>
      <description><![CDATA[如下文本：

希望能够对重复的行进行统计。

首先，不能希望只用 uniq 命令作用域 tmp.txt 文件，这不会找出重复的行，因为 uniq 只能处理相邻的重复行。因此，如果想列出重复行，需要先 sort 之后再用 uniq ，如：

其中，uniq 的 -d 参数要求去掉非重复的行，而只列出 ...]]></description>
      <category>Shell Examples</category>
      <author>beyes</author>
      <pubDate>Fri, 18 Jan 2013 16:20:48 +0000</pubDate>
    </item>
    <item>
      <title>字符串的连续连接操作</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=7463</link>
      <description><![CDATA[下面例子演示对一个字符串进行多次连接的操作：
[mw_shl_code=bash,true]#!/bin/sh
 
 tmpstr=\'458976\'
 
 declare -A myarr
 
 full=\'0x33,\'
 
 myarr=([\'0\']=0x30 [\'1\']=0x31 [\'2\']=0x32 [\'3\']=0x33 [\'4\']=0x34 [\'5\']=0x35 [\'6\']=0x36 [\'7\']=0x37 [\'8\']=0x38 [\'9\']=0x ..]]></description>
      <category>Shell Examples</category>
      <author>beyes</author>
      <pubDate>Sat, 06 Oct 2012 17:16:45 +0000</pubDate>
    </item>
    <item>
      <title>批量制作十六进制数</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=7456</link>
      <description><![CDATA[需要用多个十六进制整数初始化 C 程序中的字符数组(shellcode)，但是现在从某个编辑器中复制到的十六进制数并没有前缀 0x 以及每个字节后的逗号：

 
使用 sed 的正则表达式处理如下：

命令中的 &amp; 符号表示匹配部分，-r 选项表示使用正则表达式。]]></description>
      <category>Shell Examples</category>
      <author>beyes</author>
      <pubDate>Fri, 05 Oct 2012 00:47:37 +0000</pubDate>
    </item>
    <item>
      <title>统计单列数据总数</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=7124</link>
      <description><![CDATA[今天看了一下盛大的 CDN 加速流量统计，一天下来差不多已达到 1G ，有点吃惊，登录盛大的云分发控制台看下报表，只见它是每 5 分钟统计一次流量，而且都是小小几M不等，但报表上并没有统计这些流量的总数，怀疑这些流量加起来真的有这么多么？
 
 
于是就想自己算了一下 ...]]></description>
      <category>Shell Examples</category>
      <author>beyes</author>
      <pubDate>Fri, 01 Jun 2012 08:27:59 +0000</pubDate>
    </item>
    <item>
      <title>大量转载 QZONE 里的图片</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=6930</link>
      <description><![CDATA[有时在别人的 QQ 空间里发现许多不错的图片，想将它们全部转载到论坛上来，但是数目太多，如果每个都另存为下来，然后逐个上传为论坛附件保存那工作量会相当之大。

之前，我们论坛提供了一个可以突破某些网站防盗链图片的一个网址，即 http://www.groad.net/pic.php?ur ...]]></description>
      <category>Shell Examples</category>
      <author>beyes</author>
      <pubDate>Sat, 28 Apr 2012 08:16:45 +0000</pubDate>
    </item>
    <item>
      <title>使用 lynx 提取七星彩</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=6851</link>
      <description><![CDATA[lynx 是一个基于命令行的浏览器。我们很多时候在提取网页内容时，可能使用的方法是使用 wget 或 curl 先将网页另存为到本地，然后分析网页源码，最后过滤掉 HTML 标签及其它无用的信息。然而，如果利用 lynx 的 -dump 功能，那么将省去分析网页源码的步骤，大大简化了工 ...]]></description>
      <category>Shell Examples</category>
      <author>beyes</author>
      <pubDate>Mon, 09 Apr 2012 05:47:40 +0000</pubDate>
    </item>
    <item>
      <title>回文检测</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=6847</link>
      <description><![CDATA[像 noon, poop peep, civic, radar 这些都是回文单词，回文单词简单的说就是无论顺序念还是倒叙念都一样的词。

下面的这个脚本可以检测回文单词：
[mw_shl_code=bash,true]#!/bin/bash

if [ $# -ne 2 ];
then
&#160;&#160;&#160;&#160;echo \&quot;Usage: $0 filename strin ...]]></description>
      <category>Shell Examples</category>
      <author>beyes</author>
      <pubDate>Sun, 08 Apr 2012 02:04:19 +0000</pubDate>
    </item>
    <item>
      <title>javascript 代码的压缩与解压缩</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=6844</link>
      <description><![CDATA[编写 javascript&#160;&#160;和其它代码一样，为了容易阅读，经常会添加注释与排版，而在排版里，会有许多空格，制表，以及换行缩进等。这样一来，在最后使用这些代码时，会增加文件的尺寸，也增加了页面的加载时间，解决这个问题的方法是压缩代码，也就是去掉那些空格 ...]]></description>
      <category>Shell Examples</category>
      <author>beyes</author>
      <pubDate>Sat, 07 Apr 2012 05:01:06 +0000</pubDate>
    </item>
    <item>
      <title>迭代文件中的行，行中的单词，单词中的字符</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=6840</link>
      <description><![CDATA[1. 迭代文件中的行
可以使用 while 从标准输入依次读入文件中的每一行，下面是供测试文本，共 2 行：

 
脚本代码：

 
运行输出：

 
 ...]]></description>
      <category>Shell Examples</category>
      <author>beyes</author>
      <pubDate>Fri, 06 Apr 2012 05:39:04 +0000</pubDate>
    </item>
    <item>
      <title>统计文本中单词的使用次数</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=6823</link>
      <description><![CDATA[下面脚本用以统计一个文本中每个单词的使用次数：
[mw_shl_code=bash,true]#!/bin/bash

if [ $# -ne 1 ];
then
    echo \&quot;Usage: $0 filename\&quot;;
    exit -1
fi

filename=$1

egrep -o \&quot;\\b[[:alpha:]]+\\b\&quot; $filename | awk \'{ count[$0]++ } END { printf(\&quot;%-14s\\n\&quot;,  ...]]></description>
      <category>Shell Examples</category>
      <author>beyes</author>
      <pubDate>Wed, 04 Apr 2012 03:41:43 +0000</pubDate>
    </item>
    <item>
      <title>匹配 IPv4 地址</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=6821</link>
      <description><![CDATA[匹配 IPv4 地址的正则一般可以写成下面两种样式：



或者



举例：]]></description>
      <category>Shell Examples</category>
      <author>beyes</author>
      <pubDate>Tue, 03 Apr 2012 10:54:05 +0000</pubDate>
    </item>
    <item>
      <title>利用 dropbox 定时远程本地备份数据</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=6813</link>
      <description><![CDATA[下面的代码来自 hostloc 网友 xyz ，未经验证。

新建一个脚本：
vi dropbox.sh
[mw_shl_code=bash,true]#!/bin/bash
DROPBOX_USER=\&quot;dropbox邮箱帐号\&quot;
DROPBOX_PASS=\&quot;dropbox密码\&quot;
#dropbox上传目录 默认是dropbox文件夹
DROPBOX_DIR=\&quot;/dropbox\&quot;
#要备份的文件路径
BACK ...]]></description>
      <category>Shell Examples</category>
      <author>beyes</author>
      <pubDate>Sun, 01 Apr 2012 11:38:28 +0000</pubDate>
    </item>
    <item>
      <title>统计某个目录下所有文件类型的文件个数</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=6805</link>
      <description><![CDATA[下面代码统计某目录下所有的文件类型相对应的文件个数，代码如下：
[mw_shl_code=bash,true]#!/bin/bash

if [ $# -ne 1 ];
then
    echo $0 you_ path;
    echo
fi

path=$1

declare -A statarray;

while read line;
do
    ftype=`file -b \&quot;$line\&quot; | cut -d, -f1` ...]]></description>
      <category>Shell Examples</category>
      <author>beyes</author>
      <pubDate>Fri, 30 Mar 2012 09:38:32 +0000</pubDate>
    </item>
    <item>
      <title>删除重复文件并保留一个拷贝副本</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=6744</link>
      <description><![CDATA[下面的代码用来删除重复文件并仅保留一个拷贝：
[mw_shl_code=bash,true]#!/bin/bash
ls -lS | awk \'BEGIN { 
&#160;&#160;&#160;&#160;getline;getline; 
&#160;&#160;&#160;&#160;name1=$8; size=$5 
&#160;&#160;&#160;&#160;}&#160;&#160;{&#160;&#160;&#160;&#160; ...]]></description>
      <category>Shell Examples</category>
      <author>beyes</author>
      <pubDate>Thu, 29 Mar 2012 04:06:20 +0000</pubDate>
    </item>
    <item>
      <title>统计一个字符串中各个重复字符的个数</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=6710</link>
      <description><![CDATA[统计一个字符串中各个重复字符的个数的一个方法如下：

上面，sed 命令中 [^\\n] 表示不匹配换行符的单个字符，因此 sed 在扫描该行时会在非换行符的字符后添加上一个换行符，这样输出时就是每个字符作为一行输出。其中 &amp; 符号代表前面的匹配部分。
还可以进一步写成：

 ...]]></description>
      <category>Shell Examples</category>
      <author>beyes</author>
      <pubDate>Sat, 24 Mar 2012 07:04:49 +0000</pubDate>
    </item>
    <item>
      <title>读取 gmail 未读邮件</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=6235</link>
      <description><![CDATA[下面这个脚本用来读取 gmail 中的未读邮件，默认输出头 5 封未读邮件，每一封未读邮件以下列行书输出：


脚本代码如下：
[mw_shl_code=bash,true]#!/bin/bash


username=\&quot;你的GMAIL用户名\&quot;
password=\'你的GMAIL密码\'
SHOW_COUNT=5 #输出头 5 封未读邮件
echo
curl-u $ ...]]></description>
      <category>Shell Examples</category>
      <author>beyes</author>
      <pubDate>Wed, 22 Feb 2012 12:14:44 +0000</pubDate>
    </item>
    <item>
      <title>PPTP VPN 自动安装 脚本(CentOS6.0)</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=5309</link>
      <description><![CDATA[这个脚本适用于 CentOS6.0 ，自动生成密码和用户名。
[mw_shl_code=text,true]yum remove -y pptpd ppp
iptables --flush POSTROUTING --table nat
iptables --flush FORWARD
rm -rf /etc/pptpd.conf
rm -rf /etc/ppp

wget http://poptop.sourceforge.net/yum/s ...]]></description>
      <category>Shell Examples</category>
      <author>beyes</author>
      <pubDate>Sun, 20 Nov 2011 09:02:00 +0000</pubDate>
    </item>
    <item>
      <title>pptpd vpn 服务器自动安装脚本(Debian)</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=5298</link>
      <description><![CDATA[安装 VPN ，对于个人用来来说好处莫过于跳到墙外面看一些被河蟹的东西。若基于此目的，那么在安装VPN 之前应该确保自己有一部国外的 VPS 或者独立服务器。下面转载一个自动化代码，使省去手动安装的麻烦。另外，如果是 VPS，一般有两种，一种是基于 XEN 的，一种是基于  ...]]></description>
      <category>Shell Examples</category>
      <author>beyes</author>
      <pubDate>Sat, 19 Nov 2011 14:56:21 +0000</pubDate>
    </item>
    <item>
      <title>大范围搜索反向 DNS</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=5225</link>
      <description><![CDATA[下面代码大范围 IPV4 的反向 DNS 地址，去掉几个内网地址段(不是十分精确)：
[mw_shl_code=bash,true]#!/bin/sh


for d in $( seq 1 254 )
do
   for c in $( seq 1 254 )
     do
        for b in $( seq 1 254 )
          do
             for a in {1..9}  {11..1 ...]]></description>
      <category>Shell Examples</category>
      <author>beyes</author>
      <pubDate>Fri, 11 Nov 2011 06:37:44 +0000</pubDate>
    </item>
  </channel>
</rss>