Skip to content

Building my own version of the Unix command line tool wc

Notifications You must be signed in to change notification settings

mariollesta/my-own-wc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Writting my own wc Unix tool


About

Following the guidelines of the Coding Challenges blog, the goal of this project is the development of a proprietary version of the Unix command line tool wc, which it's been called mywc.

The wc command is used to count the number of lines, words and bytes in a text file passed as a parameter. On the other hand, if no text file is specified, the command will read from the standard input.

Give me a star if you find it useful :)


Requirements

Python PyPI


Set up

Download the application repository:

git clone https://github.com/mariollesta/my-own-wc.git

Note

It will be downloaded to the directory where we are located in our terminal by executing the command

Install the packages:

  • To install the package locally in the user's directory, which means that it will only be available to the user who performed the installation
pip install --user <PATH>/mywc-<version>-py3-none-any.whl
  • To install the package globally on the system, which means that it will be available to all users on the system. May require elevated (administrative) permissions to install the package.
pip install <PATH>/mywc-<version>-py3-none-any.whl

Note

If the program does not work, check that the directory where the executable is located is in the PATH variable of the system.


How to use

You can use the attached file in the repository "test.txt" to test the operation of the application.

To see the operation and options of the program, we run it with the help option:

mywc --help

You will see something like what is shown in the following image:

In this way, you will be able to see how the tool works as well as the options available to you.

Afterwards,

if you want to know the number of bytes in a file, you would execute the command:

mywc --c <PATH to FILE> 

if you want to know the number of lines:

mywc --l <PATH to FILE> 

if you want to know the number of words:

mywc --w <PATH to FILE>

if you want to know the number of charecters:

mywc --m <PATH to FILE>

Finally, if no options are provided, it is the equivalent to the -c, -l and -w options.

mywc <PATH to FILE>

In addition, as the help shows, if no file is provided, it will try to read from the standard input. So, if we wanted to count the bytes of a file by reading from the standard input we could do it as follows:

cat <PATH to FILE> | mywc --m 

About

Building my own version of the Unix command line tool wc

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages