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
3 answers

Different result when count line number of a file, using wc -l and cat -n

I heard that wc -l could count the number of lines in a file. However, when I use it to count lines of a file that was generated by Python, it gives a different result, miscounting one line. Here is the MWE. #!/usr/bin/env python …
Ch'en Meng
  • 363
  • 3
  • 14
0
votes
1 answer

echo wc result not right in shell script

this is my shell script #!/bin/sh echo "====" echo $1 echo "====" ps -ef | grep -w $1 | grep -v -e "grep" echo "====" echo $(ps -ef | grep -w $1 | grep -v -e "grep" | wc -l) echo "====" exit 0 then,i execute the shell script at command…
0
votes
2 answers

get format on int for awk print

I want the number of lines of my python files with relative path. I get that like this:: $ find ./ -name "*.py" -exec wc -l {} \;| awk '{print $1, $2}' 29 ./setup.py 28 ./proj_one/setup.py 896 ./proj_one/proj_one/data_ns.py 169…
user3313834
  • 7,327
  • 12
  • 56
  • 99
0
votes
1 answer

Count file in linux by between date time

I would like to ask about how to count the number of files in linux by between two dates and times? Example I have 10 file like: Date Modified Filename 2016101500 1.file 2016101501 2.file 2016101502 3.file 2016101503 …
Sidara KEO
  • 1,693
  • 1
  • 14
  • 34
0
votes
1 answer

How to check the record in a spooled file in Unix

I have to generate a csv file by creating a sql query(oracle) and then mail it to the user. Up to this part I have completed and is working fine. But if there is any data returned in the spooled file, then only the mail need to be sent. I am having…
J.Verma
  • 1
  • 1
0
votes
1 answer

Find the number of regular files and directories in current directory and sub-directories INCLUDING current directory

Question is in the title, Obviously I know that what I am asking in just equal to: 1 + find . -type f | wc -l So my question is how you can combine both ? Many thanks in advance !! Best Regards,
Antonin GAVREL
  • 9,682
  • 8
  • 54
  • 81
0
votes
4 answers

UNIX: Physical Location of "wc" command. It ain't "/bin"

This has be stump. I wrote a shell program in C that allows the user to execute several commands. Based on my research so far, all the commands such as "ls" and "cat" are located in "/bin/". The "wc" is not listed in this directory - "/bin". If…
learning
  • 3
  • 1
  • 2
0
votes
1 answer

mysql substring/left command isnt returning correct number of characters

I'm executing the following statement: select left(column,400) from table into outfile test; I've also tried using substring function (with same results). When I go to download the file and get a character count: wc -c < test I get 409 characters…
user3299633
  • 2,971
  • 3
  • 24
  • 38
0
votes
1 answer

using find sort and wc -l in the one command

This is how find files using find and show the number of lines in each file $ find ./ -type f -name "data*.csv" -exec wc -l {} + 380723 ./data_2016-07-07-10-41-13.csv 369869 ./data_2016-07-11-10-42-01.csv 363941…
HattrickNZ
  • 4,373
  • 15
  • 54
  • 98
0
votes
3 answers

Count lines in a file using bash and add the result in the first line

I have a text file: 10 20 30 40 50 60 60 80 By using $ wc -l file.txt 2 file.txt I get the count, but I want to add that result in my text file. I want the result to be like this: 2 10 20 30 40 50 60 70 80 What should I do in order to prepend the…
BHAV247
  • 69
  • 1
  • 11
0
votes
1 answer

The use of pipping and wc -w in UNIX

I had a midterm exam and one of the questions were: what does the following command do step by step: cat file1.txt | wc | wc -w > file2 Then What would be displayed on the standard out of "cat file2" For the first part: I wrote that cat temp.txt…
Jesus Mesus
  • 13
  • 1
  • 4
0
votes
1 answer

I'm trying to understand how to use special characters in grep and wc

Can you explain in detail what happened here on this command? grep -nw '^root' /etc/passwd What is the use of ^ and '? Please give me examples and be detailed cuz all I'm hearing is that it's the beginning of the line. I don't understand what each…
user6260366
  • 47
  • 1
  • 7
0
votes
1 answer

Why does wc count one extra character in my file?

1.) I am using Debian 8.4 on a virtual box and as I ran the command wc sample.txt to sample.txt containing: Hello The output to the command was 1 1 6 sample.txt Is the extra character EOF? If it is then how come when I ran the same command for an…
Patrick
  • 191
  • 2
  • 8
0
votes
1 answer

Executing wc command on child process using pipeline

I'm writing a program that executes the word count command on the child process. The father process should send a sequence of lines entered by the user trough a pipeline to the child process. I tried to do this but I ended up with an error. This is…
José Cunha
  • 107
  • 1
  • 9
0
votes
1 answer

one command line grep and word count recursively

I can do the following using a for loop for f in *.txt; do grep 'RINEX' $f |wc -l; done Is there any possibility to get an individual file report by running one liner? Meaning that I want to grep & wc one file at the time in a similar fashion…
AjanO
  • 433
  • 1
  • 9
  • 20