From 34bc8fec31227ee8b1555e23a8b3c42f6d8f390c Mon Sep 17 00:00:00 2001 From: Advay Tandon Date: Mon, 22 Oct 2018 21:14:39 -0400 Subject: [PATCH 1/3] Created basic reference guide for wc. Added a basic syntax example, and the list of options. --- _commands/basics/wc.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 _commands/basics/wc.md diff --git a/_commands/basics/wc.md b/_commands/basics/wc.md new file mode 100644 index 000000000..7f335c9ee --- /dev/null +++ b/_commands/basics/wc.md @@ -0,0 +1,31 @@ +--- +--- + +wc +--- +'wc' is a command used to find out the number of lines, word count, byte or character counts in the files specified. + +~~~ bash +$ wc [options] filenames +~~~ + + + +### Basic Usage + +~~~ bash +$ wc filename.txt +12 16 112 filename.txt +~~~ + +Here, the file called filename.txt has **12** lines, **16** words, and has a byte count of **112**. + +### Useful Options + +~~~ bash +wc -l : Prints the number of lines in a file. +wc -w : prints the number of words in a file. +wc -c : Displays the count of bytes in a file. +wc -m : prints the count of characters from a file. +wc -L : prints only the length of the longest line in a file. +~~~ From e0c3a9590639cacad7d874f12109d8ae08ce7c9a Mon Sep 17 00:00:00 2001 From: Advay Tandon Date: Mon, 22 Oct 2018 21:37:17 -0400 Subject: [PATCH 2/3] Added a few more examples for the various options, add references. Modified some style choices. --- _commands/basics/wc.md | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/_commands/basics/wc.md b/_commands/basics/wc.md index 7f335c9ee..d64ee37c6 100644 --- a/_commands/basics/wc.md +++ b/_commands/basics/wc.md @@ -3,7 +3,7 @@ wc --- -'wc' is a command used to find out the number of lines, word count, byte or character counts in the files specified. +`wc` is a command used to find out the number of lines, word count, byte or character counts in the files specified. ~~~ bash $ wc [options] filenames @@ -29,3 +29,33 @@ wc -c : Displays the count of bytes in a file. wc -m : prints the count of characters from a file. wc -L : prints only the length of the longest line in a file. ~~~ + +### Examples + +**Number of Lines** +~~~ bash +$ wc -l filename.txt +12 filename.txt +~~~ +--- +**Number of Words** +~~~ bash +$ wc -w filename.txt +16 filename.txt +~~~ +--- +**Length of Longest Line** +~~~ bash +$ wc -L filename.txt +16 filename.txt +~~~ +--- + +### For More Help +For more information and help on the **wc** command, run `wc --help` or `man wc` from the command line. + +### References + +* [TecMint: 6 WC Command Examples to Count Number of Lines, Words, Characters in Linux](https://www.tecmint.com/wc-command-examples/) +* [GeeksforGeeks: wc command in Linux with examples](https://www.geeksforgeeks.org/wc-command-linux-examples/) + From e6f9100ce8f59d7bc90b4c3ef7a3147e54d2fb1d Mon Sep 17 00:00:00 2001 From: Advay Tandon Date: Mon, 22 Oct 2018 21:40:25 -0400 Subject: [PATCH 3/3] Corrected some mistakes with style and formatting. --- _commands/basics/wc.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/_commands/basics/wc.md b/_commands/basics/wc.md index d64ee37c6..a2b327d7f 100644 --- a/_commands/basics/wc.md +++ b/_commands/basics/wc.md @@ -33,22 +33,28 @@ wc -L : prints only the length of the longest line in a file. ### Examples **Number of Lines** + ~~~ bash $ wc -l filename.txt 12 filename.txt ~~~ + --- **Number of Words** + ~~~ bash $ wc -w filename.txt 16 filename.txt ~~~ + --- **Length of Longest Line** + ~~~ bash $ wc -L filename.txt 16 filename.txt ~~~ + --- ### For More Help