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

wc -m in linux excess 1 value

md5sum file.png | awk '{print $1}' | wc -m I get: 33 I expect it will return 32 as the length of md5 hash. After read man page and googling I still didn't find out why.
Stephen
  • 45
  • 6
0
votes
2 answers

How to find files and count them (storing the info into a variable)?

I want to have a conditional behavior depending on the number of files found: found=$(find . -type f -name "$1") numfiles=$(printf "%s\n" "$found" | wc -l) if [ $numfiles -eq 0 ]; then echo "cannot access $1: No such file" > /dev/stderr; exit…
user3341592
  • 1,419
  • 1
  • 17
  • 36
0
votes
2 answers

new svn server, same ip

Here is my problem: My server crashed last night! So i had to go out and buy some new stuff and i now have a new server. I have everything set back up and i am trying to set my svn server back up. I have it set back up. I have my files on another pc…
prolink007
  • 33,872
  • 24
  • 117
  • 185
0
votes
0 answers

K&R C - Testing Wordcount program

The following code is from K&R The C Programming Language. I compile the code with gcc wordCount.c on a UNIX system through putty. After compiling I run ./a.out and regardless of what arguments I pass after ./a.out it returns nothing and loops…
Link79097
  • 68
  • 3
  • 6
0
votes
1 answer

Why does the number of lines in a file reported by wc differ from the number of records read by awk?

When I count the number of lines in a file using awk: cat ~/.account | wc -l ... the result is: 384 But when I use awk: awk 'BEGIN {x = "1.02"; y = 0; } {x = x*2; y = y + 1} END {print x; print y}' ~/.account ... the result…
Duc Chi
  • 391
  • 4
  • 8
0
votes
1 answer

Count the number of lines in a text file that contain a specific character (Linux)?

I have a .csv (utf-8 text file). It has millions of lines. I can count the lines with wc -l. I want to count only lines with specific characters in them. So if 2M of 10M lines had a "1" in them, I'd like to return 2M. Is this possible? Will this be…
T. Brian Jones
  • 13,002
  • 25
  • 78
  • 117
0
votes
6 answers

Count total number of pattern between two pattern (using sed if possible) in Linux

I have to count all '=' between two pattern i.e '{' and '}' Sample: { 100="1"; 101="2"; 102="3"; }; { 104="1,2,3"; }; { 105="1,2,3"; }; Expected Output: 3 1 1
0
votes
3 answers

> and < difference Bash

I have to test if pathname is a regular file and if it's length is greater 50 bytes , for this reason I do like this: if [[ -f $path && `wc -c < $path` -gt 50 ]]; then ...... and it works , but , for curiosity , I tried to do also like this: if [[…
gino gino
  • 249
  • 1
  • 4
  • 8
0
votes
0 answers

mismatch between number of documents indexed in solr and file count in linux

I have a ton of documents in a directory but I dont know how many there are. I used the command ls -lf xmlFiles | wc -l to count, and it gives 981,266 files. The issue is I ran another command to index them into solr find xmlFiles/ -exec…
yemista
  • 433
  • 5
  • 15
0
votes
2 answers

How to count number of lines of a file hdfs?

I'm trying to count the number of lines in a file in hdfs/HIVE. There are some cases where I want the number of lines of the entire table in HIVE, and some cases where I want the number of lines just in a file in HIVE. I've tried some things like…
makansij
  • 9,303
  • 37
  • 105
  • 183
0
votes
2 answers

Python - Word Count script

Down below is Python word count script that I found online, I am having difficulty understanding how you would run this though. Would I need to create a file and open it in Python before running this program for it to work? #!/usr/bin/env…
aznjonn
  • 113
  • 16
0
votes
2 answers

how to make csv file split the lines appropriately?

I have an enormous csv file, about 100 M. I try to do a head on it, and it spits out the entire csv, regardless of the number of lines I ask for. head data.csv AND head -1 data.csv give the same result, i.e. the entire file. I notice later that…
makansij
  • 9,303
  • 37
  • 105
  • 183
0
votes
1 answer

Count number of files in directory then scp transfer a certain range such as 21404-42806

I found the number of files in /dev/shm/split/1/ to be 42806 using: /bin/ls -lU /dev/shm/split/1/ | wc -l What I can't seem to find anywhere online is how to select a certain range, say from 21404-42806, and use scp to securely copy those files.…
technerdius
  • 253
  • 3
  • 6
  • 16
0
votes
2 answers

Made a wc program in Java, but it will not count end of line character

So I have pretty much completed (I think) my wc program in Java, that takes a filename from a user input (even multiple), and counts the lines, words, bytes (number of characters) from the file. There were 2 files provided for testing purposes, and…
Camdeazy
  • 23
  • 4
0
votes
2 answers

how many characters should wc -c actually return under FreeBSD?

In FreeBSD 10.2 , I want to experiment with "wc -c". I created the file su.c in which I typed "hello , Jack." - only 13 characters. I didn't type the enter key - there is only one line. Why wc -c tells me there are 14 characterss…
PPJack
  • 95
  • 1
  • 6