现在的位置: 首页 > 综合 > 正文

查找linux command source code

2013年03月06日 ⁄ 综合 ⁄ 共 1147字 ⁄ 字号 评论关闭

 

# rpm -qif `which sort`

 

Name        : coreutils                    Relocations: (not relocatable)

Version     : 5.2.1                             Vendor: CentOS

Release     : 31.4                          Build Date: Sun 13 Aug 2006 10:26:34 AM GMT

Install Date: Sat 17 Mar 2007 07:25:40 AM GMT      Build Host: build-i386

Group       : System Environment/Base       Source RPM: coreutils-5.2.1-31.4.src.rpm

Size        : 7308841                          License: GPL

Signature   : DSA/SHA1, Sun 13 Aug 2006 12:54:58 PM GMT, Key ID a53d0bab443e1821

Packager    : Johnny Hughes <johnny@centos.org>

URL         : ftp://alpha.gnu.org/gnu/coreutils/

Summary     : The GNU core utilities: a set of tools commonly used in shell scripts

Description :

These are the GNU core utilities.  This package is the combination of

the old GNU fileutils, sh-utils, and textutils packages.

 

 

若是下载的src.rpm源码包,则:

  1、rpm2cpio coreutils-5.2.1-31.8.el4_7.1.src.rpm| cpio -idv

  2、此时会在当前目录下产生coreutils-5.2.1.tar.bz2文件

  3、bzip2 -d coreutils-5.2.1.tar.bz2 解压,会产生coreutils-5.2.1.tar 文件

  4、tar xvf coreutils-5.2.1.tar 此时在当前目录下将产生coreutils-5.2.1目录,源码便在其中。

  进入coreutils-5.2.1目录,下面的src文件夹便是存放cat命令源代码的地方,当然了除了cat,linux的很多基础的外置命令的源代码都存放其中,像cp,chown,chmod,df,ls,rm,dd等等

  对了,顺便说一下,coreutils-5.2.1目录下的configure脚本有5w多行哦,里面体现了很多shell的编程技巧,很值得喜欢shell并且想进一步深入学习shell编程的朋友去拜读一下哦。

 

【上篇】
【下篇】

抱歉!评论已关闭.