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
-1
votes
1 answer

Linux, Find > zcat > wc

a have many zip files on my system. I need to calculate quantity of symbol all of them. But my command doesn't work: [zola@n.korea ~]$ find /RAID/s.korea/onlyzip/ -name *.zip -type f -exec zcat {} \; |wc -c gzip:…
Zola7d
  • 3
  • 1
  • 2
-1
votes
2 answers

Line count in UNIX by reading file name from another file

I have a file FILE1.TXT. It contains only one file name FILE2.TXT. How will I find the record count / line count of FILE2.TXT using only FILE1.TXT? What I have already tried is: cat FILE1.TXT | wc -l But the above command did not work. Actually, I…
TechVolcano
  • 221
  • 1
  • 3
  • 13
-1
votes
2 answers

Always keep n newest files in dir

I'm trying to create a one-liner which should remove excess files from dir to save it from consuming too much space. ls -r --sort=time | head -${{ls | wc -l} - n} | xargs rm -f n should stand for number of files I want to keep in directory. I'm…
Zloj
  • 2,235
  • 2
  • 18
  • 28
-1
votes
1 answer

What is the difference between commands "wc `grep -l int *`" and "grep -l int * | wc"?

What is the difference between these two commands: wc `grep -l int *` grep -l int * | wc How does the output differ?
cyborg95
  • 185
  • 11
-1
votes
2 answers

Number of lines differ in text and zipped file

I zippded few files in unix and later found zipped files have different number of lines than the raw files. >>wc -l 70308 /location/filename.txt 2931 /location/filename.zip How's this possible?
Kuber
  • 1,023
  • 12
  • 21
-1
votes
3 answers

Using read line in KSH not selecting last line in file

I have a file which would contain something like: CUSTOMER_MSISDNS 447999999999 The list of MSISDNs can carry on and be unlimited, and there is no set position where this section may be in the file due to expanding top elements, so to find the line…
Charabon
  • 737
  • 2
  • 11
  • 23
-1
votes
1 answer

select and copy files with N lines

I would like to select and copy from a folder only the files with a number N of lines. How it is possible to do this in Bash? Al.
altroware
  • 940
  • 3
  • 13
  • 22
-1
votes
2 answers

What does & do at the end of a wc command?

I am learning the bash environment and cannot understand what I get when running this command: wc filename.txt & It returns an array with a 1-digital integer and another integer, neither of them matches any other result I can get from wc commands…
Barb Wire
  • 13
  • 5
-1
votes
2 answers

Count # lines in perl using wc

This seems really simple but neither a google search nor a stackoverflow search turn anything up. Is there a reason people don't do it this way? Sorry if I'm missing something. I tried $B = `wc -l $fileB`; print "$B\n"; @B_array = split /\s+/, $B;…
Michael Starr
  • 7
  • 1
  • 11
-1
votes
1 answer

Is something wrong with my use of wc or grep in the linux command line? I"m getting +1 on my char count

When I run echo "obase=2;3" | bc | grep -v \n\s | wc -m bash returns 3. But when I run echo "obase=2;3" | bc bash returns 11. Why is wc -m one digit high on its count?
jeffmjack
  • 572
  • 4
  • 14
-2
votes
1 answer

Using the line count command wc -l (Linux), I am getting a return of the number of lines minus 1

It looks like the number of carriage returns is what is being counted. Also, the command line is concatenated with the last line of text when I do the cat command. So, cat newdoc gives me the last line be savedorangepi@OrangePi:~ where 'be saved' is…
-2
votes
2 answers

comparing line count in multiple text files

I have multiple text files in a directory and want to compare line count for each file against each other. Below is my code but the output is incorrect; it's always showing me "bigger" whatever the line count. for f in *.txt; do for f2 in *.txt;…
user2334436
  • 949
  • 5
  • 13
  • 34
-2
votes
3 answers

How to add number of identical line next to the line itself?

I have file file.txt which look like this a b b c c c I want to know the command to which get file.txt as input and produces the output a 1 b 2 c 3
e271p314
  • 3,841
  • 7
  • 36
  • 61
-3
votes
1 answer

How to use bash's grep in perl?

I would like to run the following unix command in perl: grep -r "some_word" /path/to/directory | wc -l (The goal is to see how many times does "some_word" appear in a directory and all its inside-folders/files. What is Perl's equvalence? I tried…
urie
  • 361
  • 2
  • 14
-3
votes
2 answers

How to count characters between tabs that are greater than 8000 in linux

I have a file for example file.dat.gz that is tab delimited. For example hi^Iapple^Itoast is it possible to count in between the tabs using wc? Since the above counts would be 2, 5, 5 wc would return 0 but if it was greater than 8000 could it…
I eat toast
  • 117
  • 6
1 2 3
23
24