Skip to main content

Questions tagged [wc]

`wc` utility counts newline, word, and byte for file(s) or standard input.

Filter by
Sorted by
Tagged with
2 votes
1 answer
177 views

I expected these two commands to give the same count of how many lines in my file contain a letter: grep -c '[A-Z,a-z]' archive_for_TO.050225 11873 grep '[A-Z,a-z]' archive_for_TO.050225 | wc -l 11859 ...
Tim Osborn's user avatar
4 votes
1 answer
191 views

The distro is Ubuntu 22.04 and I'm running a newly-created ext4 filesystem that I have copied my setup to (using rsync on a different machine). I was running a manually written (python) filesystem ...
Elisa K. K.'s user avatar
0 votes
3 answers
146 views

I am trying to normalise a data file using the number of lines in a previous version of the data file. After reading these questions, I thought this could work: awk -v num=$(wc -l my_first_file.bed) '{...
Whitehot's user avatar
  • 245
0 votes
2 answers
81 views

I have some text files the looks something like this: Introduction and some meta data [00:00.000 --> 00:04.380] Lorem ipsum dolor sit amet, consectetur adipiscing elit. [00:04.980 --> 00:07.200]...
d-b's user avatar
  • 2,077
0 votes
0 answers
95 views

Running wc with multiple files is an order of magnitude faster than running it file by file. For example: > time git ls-files -z | xargs -0 wc -l > ../bach.x real 0m2.765s user 0m0.031s ...
tmaj's user avatar
  • 101
0 votes
0 answers
75 views

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
0 votes
2 answers
255 views

Getting Error with the below command to check on the Remote directory a specific type of files. The requirement is to get the count of the specific files. file_exists=$(sftp $FTP_UNAME@$FTP_HOST ls *$...
MALABIKA GARAI's user avatar
0 votes
0 answers
84 views

When running wc -l models.txt, we get the output which looks like 2113 models_work.txt. I wonder how to get the 2113 from that output using the cut command or something along those lines. It doesn't ...
Tung's user avatar
  • 171
0 votes
1 answer
74 views

find /volume1/file/* -type f \( -name "*DF*" -a -name "*LIVE*" \) -print0 | while IFS= read -d '' file do # extract the name of the directory to create dirName="${file%...
anisphia's user avatar
6 votes
2 answers
1k views

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
165 views

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
0 votes
1 answer
1k views

with command wc -l filename it is showing one row less when total number of rows inside file are 2 but it is showing 1 only. Please guide.
user555948's user avatar
5 votes
2 answers
2k views

I want to see how many lines exist in each file that has been found using the find command. I know I can use wc -l to find the lines number of a single file. But this does not work when piped from the ...
Saeed Neamati's user avatar
18 votes
3 answers
4k views

I have a command <streaming ls> | wc -l, it works fine, but the <streaming ls> takes a while, which means I don't get the final line count until a few minutes later. Is there a way to have ...
Foobar's user avatar
  • 273
1 vote
2 answers
1k views

I'm trying to create a summary of how many files in a directory have n number of lines in them. I'm using wc -l * | sort to print out the number of lines against the name of each file. What I'm trying ...
Doodling's user avatar
-1 votes
1 answer
2k views

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
1k views

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
0 votes
3 answers
531 views

I have a notes.json file inside each directory. The following command counts length of each notes.json file and returns a sorted output by each file's number of lines. find . -name notes.json | xargs ...
SKPS's user avatar
  • 13
0 votes
3 answers
166 views

I'm trying to sort a directory of files by LoC. But sort appears to do nothing if the lines are piped in: paths=`find ./src/ | egrep "\.(cpp|h)$"` for path in $paths; do wc -l $path | sort -...
Jonathan Levin's user avatar
-1 votes
1 answer
125 views

How to automatically count number of lines printed by each command? Examples: $ echo xxx xxx 1 $ ls -1 xxx yyy zzz 3 $ > t0.txt 0 etc. I.e. how to correctly add | wc -l into .bashrc?
pmor's user avatar
  • 757
0 votes
1 answer
140 views

Lets say you have this program: #!/usr/bin/env python import time while True: print("True") time.sleep(1) then you run it: ./clock.py | wc -l This will never return anything ...
BigBoy1337's user avatar
2 votes
2 answers
1k views

I would like to list the files matching a specific pattern along with their number of rows. So far I have tried the following, which list me the files matching the desired pattern: find 2021.12.*/ -...
JejeBelfort's user avatar
3 votes
2 answers
5k views

Regarding wc (word count) command... I am trying to understand the following (from man wc which I have quoted below plus added a longer quote at end of my question) With no FILE, or when FILE is -, ...
PurpleMongrel's user avatar
-6 votes
2 answers
355 views

Below are the questions that I'm having trouble with, I only know how to redirect the stdout of ls to the foobar file on question 1: ls > foobar Write a command line to redirect stdout of the ...
Kudoss's user avatar
  • 1
0 votes
2 answers
132 views

I try to name a file with rows count in a crontab : * * * * * ~/script > "~/targetfile-$(rows-count).csv" I can do : * * * * * ~/script > "~/targetfile-$(~/script | wc -l).csv&...
JCH77's user avatar
  • 111
2 votes
3 answers
3k views

I learned that 'ls | wc -l' command prints number of files in the current directory, but it includes all files and directories. Can I do the same task only for pure files excluding directories?
user67275's user avatar
  • 253
4 votes
2 answers
2k views

I've created script, where I encoded string 28 times with base64. Then I wanted to echo count of chars in outputted string. First I used ${#var} which gave me 34070. Then I tried on the same string ...
unnamedrider1337's user avatar
-1 votes
1 answer
826 views

I want to print the File Name, Size of file, modification date, Number of line in a file. At present I use below command to achieve my work but it's hectic to do manually everytime ls -lrth file1.csv ...
Satya's user avatar
  • 13
1 vote
2 answers
849 views

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
1 vote
0 answers
77 views

I am trying to write a one-liner to append a row count to the filename of each file in a directory before the extension. I thought I could do this with wc -1 but I am struggling to get it in a ...
kadagreatish's user avatar
3 votes
2 answers
445 views

I'd like to count the number of elements inside a folder. I thought of function lsc { /bin/ls -l $1 | sed 1d | wc -l } but then I remembered how awk people reduced those kind of pipes, getting rid of ...
ychaouche's user avatar
  • 1,043
5 votes
5 answers
3k views

I have 35 files and directory in my home at the first level (without descending into subdirectories). But the results are "faked" and report 36 because they include the . special directory. ...
elbarna's user avatar
  • 14.5k
-3 votes
1 answer
117 views

I tried to figure out what is the difference those commands (for a school project), but for me its chrashed or running for more than 10min~ So, the sample: sudo find / -type f -exec file ’{}’ ; | ...
user439978's user avatar
0 votes
3 answers
2k views

I need help in writing script that outputs the number of lines in each of a number of large files. wc -l is taking a long time, so I'm looking to use awk command to display the last line number for ...
Rekha Mallam's user avatar
2 votes
3 answers
1k views

The problem: I have multiple text files (.fas), which look like this: file1.fas: >species1 AICGICVIAGIAIYIAAICG >species2 AICGIVVYICAGAYICAGCG file2.fas: >species1 AIG >species2 GCI I'm ...
Biomage's user avatar
  • 145
0 votes
2 answers
190 views

I have a large number of directories, and I want to count with bash commands the number of directories in each of these directories. I am having a hard time piping ls and wc to achieve what I want. E....
GZ-'s user avatar
  • 357
0 votes
1 answer
519 views

I want to write the output of wc -l to a file and before the number, I want to add the date. For example, $ wc -l file.txt 25 $ I want to append Wed Jul 8 17:30:17 +0130 2020 25 to another text ...
mahmood's user avatar
  • 1,271
0 votes
1 answer
539 views

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
2 votes
2 answers
391 views

I need to go through folders and count files in TARs with same name. I tried this: find -name example.tar -exec tar -tf {} + | wc -l But it fails: tar: ./rajce/rajce/example.tar: Not found in ...
Rajce's user avatar
  • 23
0 votes
1 answer
116 views

from a file (/etc/services) i need to take out all services, exluding all double or more entries per service, exluding lines starting with '#', sort alfabetically and store to a file. After all this ...
Dave Bulcke's user avatar
0 votes
1 answer
2k views

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
6 votes
9 answers
1k views

I want to find where a word appears in a text file — as in the number of words into the text that a word occurs — for all instances of that word, but I'm not sure even where to start. I imagine I'll ...
Johnny Rollerfeet's user avatar
4 votes
4 answers
3k views

I'm using wc -l to count the lines in output of a command, as the input is piped to it. commad | wc -l This works fine, but if command is doing some heavy computation, this is quite slow. Is there an ...
Peeyush Kushwaha's user avatar
0 votes
2 answers
94 views

I have a tsv file. For a specific value in a column 5, I want to extract all the rows, and then cut three columns and then count the unique lines. For example for string 'abc' in column 5, I want awk ...
Arsala's user avatar
  • 67
2 votes
2 answers
842 views

I've got two genetic datasets which have matching chromosome position IDs. I want to count how many times file 1's chromosome position IDs appear in file 2. For example my data looks like: File 1 (...
DN1's user avatar
  • 247
1 vote
2 answers
710 views

I have a folder with a huge file list that I want to count. I was doing ls -l *.json | wc -l and it was working fine, till the list apparently gone huge enough that this command didn't work any more. ...
elmodeer's user avatar
15 votes
4 answers
44k views

Here is the issue, I would like to count the number of jobs I have in the hpc, but it is not one of the readily provided features. So I made this simple script squeue -u user_name | wc -l where ...
zyy's user avatar
  • 321
0 votes
0 answers
810 views

I have a czv.gz file and when issuing "less" command it looks like this COLUMN1,COLUMN2,COLUMN3 ,value1,value2,value3 ,value4,value5,value6 ... There are thousands of lines in a file but when I issue ...
kamokoba's user avatar
  • 163
0 votes
4 answers
461 views

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

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