-6

I would like to create a new .wc command.

5
  • Do you want to program an script? Commented Nov 18, 2016 at 14:41
  • What did you try until now? Any specific problems? Commented Nov 18, 2016 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) Commented Nov 18, 2016 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 Commented Nov 18, 2016 at 14:56
  • yes , I want to create new script like wc command Commented Nov 18, 2016 at 14:59

1 Answer 1

2

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.