Questions tagged [wc]

`wc` is a standard POSIX command that counts words, lines, and characters.

The wc utility reads one more files (or the standard input) and writes the number of lines, words, and characters to the standard output. If more than one file is given, then the total number of lines, words, and characters across all inputs will also be printed. There are also switches for controlling what parts should be counted.

Some versions of wc can differentiate between characters (which may be multi-byte depending on the encoding) and bytes.

References:

350 questions
0
votes
1 answer

How to find the source of the wc.c?

The wc command is often touted as the fastest way to count the number of lines in a file, https://unix.stackexchange.com/questions/504892/what-is-a-quick-way-to-count-lines-in-a-4tb-file When I tried to look for the source code of wc.c that let uses…
alvas
  • 115,346
  • 109
  • 446
  • 738
0
votes
1 answer

Bash File Line Count Comparing to Integer Incorrectly

I have a simple bash script where I'm trying to iterate over the lines in a text file and calculate different metrics (moving average, derivative, etc). I'm having some trouble comparing the index iterator with the total line count and is producing…
Joshua Wilkinson
  • 133
  • 2
  • 10
0
votes
3 answers

Remove three last lines from spool file using wc -l and sed

I am facing an issue that I have File that every time have different row count and it ends with sqlldr output that shows amount of rows exported to file 40968 rows selected. Since this file will be picked up by next process I want to get rid of…
veetay
  • 13
  • 2
0
votes
1 answer

Unable to do a word count of a file through ssh in unix shell scripting

I need to go another server and perform a word count. Based on the count variable I will perform a if else logic. However i am unable to do a word count and further unable to compare the variable value in if condition. Error: wc: cannot open the…
melony_r
  • 177
  • 1
  • 1
  • 8
0
votes
1 answer

WooCommerece RestAPI - NodeJS

Im using wc rest api with nodejs and when trying to post new order via "orders" with method POST, I simply get response containing all the existing orders.. Even if not providing any request body, or providing false request body - same response…
RazProd
  • 1
  • 1
0
votes
1 answer

how to count num of containers crreated in 1 yaml file with 1 liner cmd in bash?

There is k8s pod yaml file that has 3 containers, here is the part of the yaml file: Containers: apple: Container ID: Image: busybox Image ID: Port: Host Port: Command: …
ERJAN
  • 23,696
  • 23
  • 72
  • 146
0
votes
3 answers

Awk if-statement to count the number of characters (wc -m) coming from a pipe

I tried to scratch my head around this issue and couldn't understand what it wrong about my one liner below. Given that echo "5" | wc -m 2 and that echo "55" | wc -m 3 I tried to add a zero in front of all numbers below 9 with an awk if-statement…
Ni-Ar
  • 146
  • 14
0
votes
2 answers

Using grep, to search the files in the directories, how can I get the occurrence count of each word using a list.txt(or csv)?

In the list.txt I have: Lucas Viny Froid In current directory, I have a lot csv files containing names. I need to know how many times each word of my list appears on these csv files. I tried: grep -riohf list.txt . | wc -lw But it return only the…
0
votes
0 answers

Why is wc -l counting lines incorrectly?

There is a simple command which prints the number of lines in a file.: wc -l When I use this command to a regular text file. It counts the lines correctly. But when I count the lines in some bash script, this command gives a value one line less…
0
votes
0 answers

How to do unique count with grep and wc together?

cut -f1 test.csv | wc -l I want to get the first column of the file, and do a unique count. Where can I add a 'sort u' to make it count unique lines only?
marlon
  • 6,029
  • 8
  • 42
  • 76
0
votes
1 answer

grep command not reading comamnd output for this adb command

On executing the following adb command with grep I get the following response in (darwin os) terminal. i count number of error after grep finds a "Error" string in response adb -s derefedv645xxxxxx shell "am start -n…
siva
  • 516
  • 3
  • 7
  • 22
0
votes
4 answers

Counting the number of lines of many files (only .h, .c and .py files) in a directory using bash

I'm asked to write a script (using bash) that count the number of lines in files (but only C files (.h and .c) and python files (.py)) that are regrouped in a single directory. I've already tried with this code but my calculation is always wrong let…
0
votes
1 answer

ash: -c: unknown operand

I'm trying to run a ash script that constantly checks how many characters are in a file and execute some code if it reaches at least 170 characters or if 5 seconds have passed. To do that I wanted to call wc -c, however it keeps telling me it has an…
user14490575
0
votes
0 answers

Woocommerce Custom Email trigger( custom class = class-luxwc-ishoej-order-email.php)

How to make my custom email trigger inside my email class, so that I can make it send, but only if a specific meta key and value from database is specificly meta_key = Pickup location and if the meta_value = Ishøj ? Down below here I will paste my…
FizzelTV
  • 57
  • 1
  • 8
0
votes
2 answers

Counting lines in multiple logs file, filtered by date, output with filename

I need to count lines in multiple logs file (/var/log/), filtered by date(07/Apr/2021:11), and show output with filename. Expected output: - file1.log: 25 matched lines - file2.log: 36 matched lines - file3.log: 56 matched lines I counted it with…
Kiuki
  • 624
  • 3
  • 7
  • 16