LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How to get the source code of command line ? (https://www.linuxquestions.org/questions/programming-9/how-to-get-the-source-code-of-command-line-699310/)

the_cpp 01-23-2009 03:05 AM

How to get the source code of command line ?
 
I just want to see how the command line such as : "cat", "split", "ls"...ect source code ? Are they written in C or other language ? I don't know where to search those :( ? Anyone could help me out ? Thanks in advance ;) !

w3bd3vil 01-23-2009 03:13 AM

I usually use codesearch.google.com to have a look at the source.
I did a search for you
http://www.google.com/codesearch/p?h...ard%20Stallman

David the H. 01-23-2009 03:55 AM

Remember also that bash (and other shells) also provides some built-in commands that can supersede the stand-alone ones usually found in /bin.

colucix 01-23-2009 04:07 AM

Many commands are provided by the coreutils package: you can start by downloading the coreutils source tarball and start from there. As already mentioned by David the H. some statements are BASH built-ins, hence you have to look at the BASH source code. And yes, the Linux operating system is written in C as well as most of the common utilities. If you're not sure what a command is (shell script, shell built-in, external command) you can try type.
Code:

$ type type
type is a shell builtin
$ type cat
cat is /bin/cat
$ file /bin/cat
/bin/cat: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),
for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for
GNU/Linux 2.6.9, stripped

Good luck! ;)

taylor_venable 01-23-2009 05:29 AM

Quote:

Originally Posted by colucix (Post 3418373)
If you're not sure what a command is (shell script, shell built-in, external command) you can try type.

Oh, that is cool. I didn't know about that!

the_cpp 01-24-2009 12:44 AM

Thanks a lot guys ;) ! Much more than I respected :D !

renjithrajasekaran 01-24-2009 09:01 AM

Google Is the Best place to start looking ... I am sure - with just the right amount of patience - you'll hit jackpot.
:)

Linux Archive


All times are GMT -5. The time now is 10:27 PM.