Utilize shell scripts,linux commands, open source tools,java, to Maximize the Power of Linux.
Focused on working with linux and shell, search engine technology including Chinese segmenter
Any questions please contact me at gmail: david.ullua

2/02/2007

hacking linux - find an unkown command for a desired function in a special linux distribution

If you use linux everyday, sometimes you post a problem on the newsgroup, someone would tell you a command called foobar would solve the problem. But when you type foobar in terminal, it shows "-bash: foobar: command not found", then you may wondering whether linux is as good as said, or whether your distribution is as good as others, or people had given a wrong answer. Stop wondering now,

I met the problem sometimes. and got the solution by "man -k command" .

Case 1: when i use ant files to build eclipse project, error occurred as "ant: /bin/sh^M: bad interpreter: No such file or directory." , which is described on the post:
Use eclipse with ant to deploy your java project -- from beginning of env setup to ant build .

I googled and find a post on apache mailing list, people suggest use unixdos to convert text file "ant" from dos format to unix format. I type unixdos, failed with "command not found". After thinking a while, I type :
$ man -k dos |grep -i unix
ExtUtils::MM_DOS (3) - DOS specific subclass of ExtUtils::MM_Unix
fromdos (1) - convert DOS text file format to UNIX
mcopy (1) - copy MSDOS files to/from Unix
mtools (1) - utilities to access DOS disks in Unix
todos (1) - convert UNIX text file format to DOS

Yes, fromdos, it is what i am finding. here i use man and grep to find the proper command.


Case 2: I need to convert GBK encoded text file to UTF-8 format. and googled around several times, couldn't get any useful info.

%man -k convert |grep -i encoding

the command could not find any useful command, thought it a lit while, hmmm, i need a command for character conversion

%man -k convert | grep -i character
...
%man -k conversion |grep -i character

fwprintf [wprintf] (3) - formatted wide character output conversion
iconv (3) - perform character set conversion
iconv_close (3) - deallocate descriptor for character set conversion
iconv_open (3) - allocate descriptor for character set conversion
...

Yes, iconv is exactly what i need.

No comments:

About Me

I am a senior developer and a team leader with 3 years development experience in Suzhou, China, focus on mobile web search, linux, Java and machine learning in NLP (natural language processing). My goal is to improve people's life with computer technology.