I would like to create a new .wc command.

closed as unclear what you're asking by HalosGhost, techraf, Ramesh, GAD3R, countermode Nov 18 '16 at 15:28

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Do you want to program an script? – Joshua Salazar Nov 18 '16 at 14:41
  • What did you try until now? Any specific problems? – phk Nov 18 '16 at 14:42
  • 1
    I want to create new command like wc. and subquery.. FOR example nc newfile.txt (nc = new command) 2 3 6 nc -c newfile.txt (character) 2 nc -w newfile.tx (word) – Black Nov 18 '16 at 14:45
  • If this is for an exercise, OK, but be aware that the common wc command already has command line options to count lines and characters as well as words – infixed Nov 18 '16 at 14:56
  • yes , I want to create new script like wc command – Black Nov 18 '16 at 14:59

With the exception of shell builtins, commands are just programs. This means your question reduces to, "How do I write a program?"

(Or, "How do I write a script?" which amounts to the same thing, since a script is just another type of program. The distinction between scripting and programming is not important to get into here.)

wc is a good example, because it is not a shell builtin. It is just another program on the system, typically installed in /usr/bin/wc or /bin/wc, depending on the OS.

In order to make your new command behave like the existing ones on the system, the program implementing it has to be installed somewhere in the PATH. It is common on Linux distributions to put $HOME/bin into the user's PATH if the directory is present on login. If you want the command to be available to all users on the system, you probably want to put it somewhere else, like /usr/local/bin.

Not the answer you're looking for? Browse other questions tagged or ask your own question.