Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
0 answers
44 views

When using 'wc \-l' to count the number of file lines, the result is less one [duplicate]

I want to count the number of file lines, so i use the command wc -l file. However, I notice that the result is incorrect which one less than the real number of lines. For example, the number of lines ...
Bioinfotec's user avatar
6 votes
2 answers
930 views

Why does wc and stat produce different results for /proc/[pid]/cmdline?

I am trying to understand why wc and stat report different things for /proc/[pid]/cmdline. wc says my shell's cmdline file is 6 bytes in size: $ wc --bytes /proc/$$/cmdline 6 /proc/10425/cmdline stat ...
Shane Bishop's user avatar
0 votes
2 answers
122 views

How do I count all the files at different subfolder using for loop

I want to know could I wc -l files are in subfolder.If only one file I can use code like below. find ./calss{1..20}/ -name 'C1.student' | xargs wc -l In fact, I have 20 folders , every folder contain ...
Roq's user avatar
  • 15
-1 votes
1 answer
2k views

Find how many words in a file contain a number in them?

I am trying to find the total number of words in a specific file that contain a number. Not a specific number, I'm just looking for words that contain any number at all. I tried using the grep and ...
Doug's user avatar
  • 1
0 votes
1 answer
957 views

Linux - count words with more than a certain length of characters

i want to know how to count the number of words in a .txt file that has more than 5 characters, using egrep and wc. Please, be clear as i'm new to linux.
LearningLinux's user avatar
1 vote
2 answers
775 views

$(grep -w "xyz" prog.R | wc -l) -ge 3

I am a bit new to unix and trying to figure out what the following command is doing: $(grep -w "xyz" prog.R | wc -l) -ge 3 I assume that the outcome would be boolean. The first part (i.e., ...
Bishal's user avatar
  • 11
0 votes
1 answer
456 views

Replace with lines number in specific line of a text file

What I need to do (in Bash) is a replacement of a specific characted of the second line in a text file with the number of lines in this file. So, this does the job of counting the lines: cat test.csv ...
WojtusJ's user avatar
  • 103
0 votes
1 answer
2k views

word count redirect

I can't seem to answer this question: Use the command wc to count the number of words in the file /course/linuxgym/gutenberg/0ws0310.txt. Store the exact output of the wc command when used with the ...
william's user avatar
0 votes
4 answers
348 views

Get file names of n files with highest line count

I am trying to get x amount of file names printed from highest line count to lowest. ATM i have this wc -l /etc/*.conf |sort -rn | head -6 | tail -5 | and i get this 543 /etc/ltrace.conf 523 /...
RytisAndrulionis's user avatar
0 votes
2 answers
2k views

Error in wc command to read number of lines in file

I have been using wc -l to check for the number of lines exist in my files. It worked fine always but not this time. I have 120 big files that are supposed to have at least two lines in each of them....
web's user avatar
  • 193
-2 votes
3 answers
574 views

How to count the number of occurrences of all strings in the file while getting the average of each string

I am trying to count the number of occurrences without specifying a specific string, just using the output of the cut command to print the number of each repeated string using grep. I then want to get ...
fgdark's user avatar
  • 23
0 votes
1 answer
118 views

wc behaves differently on Unix and Linux

I observed different results when I tried echoing value and counting the number of characters with "wc -c" on Linux and SunOS(Unix). root@SunOS-machine:~# echo "1" | wc -c 2 root@Linux-machine:...
Raj's user avatar
  • 203
0 votes
1 answer
282 views

How to find how many paragraphs in a file?

For example 1006.2100 49.2000 1015.6100 47.7000 1023.1100 25.2000 1024.2200 33.3000 1025.5100 26.3000 1040.6100 29.0000 1151.57 3 169.1900 31.5000 174.9900 31.5000 193.1000 19.1000 196.4500 17.9000 ...
Maurice's user avatar
  • 23
2 votes
2 answers
696 views

How to get the results of ls piped to wc when running inside of a for loop?

So I am trying to make this a single command instead of having to dump the data to a file and then cat the file and pipe the output to wc -l. The whole line of code looks like this: for file in `...
J Telep's user avatar
  • 205
3 votes
5 answers
7k views

The result of "ls | wc -l" does not match the real number of files [duplicate]

I need to count the number of files under a folder and use the following command. cd testfolder bash-4.1$ ls | wc -l 6 In fact, there are only five files under this folder, bash-4.1$ ls total 44 -...
user288609's user avatar
0 votes
0 answers
2k views

Count and compare files in Linux

I want to just compare the number of lines in two files. Below is the list of names of files. One file contains names/location of fastq files; the other file contains names/location of bam files. ...
Ron's user avatar
  • 1,087
1 vote
2 answers
502 views

wc -l command issues in SunOs to Linux migration

We are migrating from SunOS to Linux. I'm facing some problem with wc -l command. When I used wc -l <file_name>, SunOS is giving leading spaces before count where as Linux there are no leading ...
bullshot's user avatar
6 votes
3 answers
3k views

wc command counts extra characters

cat > file Amy looked at her watch. He was late. The sun was setting but Jake didn’t care. wc file 1 16 82 file Can somebody explain why wc command returns 3 extra characters in this ...
Jennifer Nghi Nguyen's user avatar
0 votes
1 answer
102 views

Big XML - copy data from nth Occurrences to another file

<XML> <Employee> <firstname></firstname><lastname></lastname> </Employee> <Employee> <firstname></firstname><lastname></lastname>...
Vijay's user avatar
  • 1
4 votes
5 answers
6k views

get file size and line count at the same time

I'm looking for a way to list all files in a directory, with both their size, and a line count. Right now I'm using stat -c \"%s %n\" /directory/* to get file names and sizes, and I know I can use ...
jmatula's user avatar
  • 43
0 votes
3 answers
1k views

Count words: what will use less CPU, wc or a perl script?

My objective is to count the words in a file while using the minimum possible CPU. I could use the wc command or write a simple perl script for this, which of the two options will be less CPU ...
yael's user avatar
  • 43