-3

I want to create one unix command, which will unzip the folder. so, I am searching for the code, but I am not aware that how should I use such code to make Unix command?

I have gone through various questions & answers but I don't get any perfect information. So, can any one please suggest me any code (in C++ or C or any language to make exe) and to use it as a Unix command.

NOTE: I know command like 'unzip' is available in 'Mks toolkit' type of software but we can not use it, so I want to make command which can run through 'command prompt'

Bhushan J
  • 3
  • 1
  • 4
  • 1
    Let's start by nailing down exactly what you're asking. (A) Can you code? (B) Do you know how to compile? ... If the answer to either of these questions is "no", then you are in the wrong place. If "yes" then please explain what is stopping you from running the program you created. – paddy Mar 25 '14 at 05:38
  • 1
    Why can you not use it? Write a script – Ed Heal Mar 25 '14 at 05:38
  • Yes Paddy, I can code, i know how to compile. – Bhushan J Mar 25 '14 at 05:55
  • Yes @Paddy,Its new to me, i have just joined this site. I can code in mostly any language, i know how to compile. The thing that I asked is **can you tell me how to create any command & can you tell me any code (in any language) to 'unzip' folder (without using 7zip or winzip exe) in the code???**. some may not able to understand the question so it doesn't mean that one can not code and there is no any rocket science to do code. I think everybody may agree with this. – Bhushan J Mar 25 '14 at 06:03
  • So, are you asking for a specification of the ZIP and 7Z formats? Your question is unclear, and rather odd. You can't just rock in here and ask how to write a complex program from scratch, with no idea how to even start. If you can code and compile, I don't really see what's stopping you from looking up the format specification(s) and writing a program using your language of preference. – paddy Mar 25 '14 at 20:33

1 Answers1

2

If you want to add a command, you only need to create your executable and put its link in the /usr/bin folder.

Just compile your code and set a link to it's executable like this:

ln -s /path/to/your_executable /usr/bin/command_name

If there exists a command that you need to modify, you should set an alias to it. For example, you want ls -1 to run whenever ls is used, then you only need to use the command:

alias ls=ls -1

or put the same command in the .bashrc file in your home directory.

orezvani
  • 3,595
  • 8
  • 43
  • 57
  • Thanks for your answer... can you tell me how to create any command & can you tell me any code (in any language) to 'unzip' folder (without using 7zip or winzip exe) in the code??? – Bhushan J Mar 25 '14 at 07:22
  • +1 @emab - this is really the only sane way to answer the question. I almost wrote something to that effect yesterday, before realising that the OP is facing a challenge on a whole different level that we can't really deal with politely. – paddy Mar 25 '14 at 20:36
  • @BhushanJ that's a different question. If you want to write a code in c++ to unzip a file, you can use `libzip`. A complete example is provided in here: http://stackoverflow.com/questions/10440113/simple-way-to-unzip-a-zip-file-using-zlib After you wrote the code, you can follow the steps in this answer to make it a unix command. – orezvani Mar 26 '14 at 04:58