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

How can I exclude results from a process count containing specific arguments?

I'm counting processes like so: ps aux | grep my_script.php | grep -v grep | wc -l But this includes results for both my_script.php foo=1 as well as my_script.php foo=1&bar=2. How can I separate these counts? I'd like to count how many include the…
Ryan
  • 14,682
  • 32
  • 106
  • 179
0
votes
3 answers

Count how many rows are in one file with defined length to show

I want to count how many rows are in one file with defined length to show. In normal case example: file: 2423 546 74868 cat file|wc -l will show the result: 3. But I want to defined length of the numbers for example to have 10 symbols and to…
Kalin Borisov
  • 1,091
  • 1
  • 12
  • 23
0
votes
2 answers

Using shell commands in knitr and displaying output

I am trying to implement shell commands in knitr and display the output in the knitted pdf document as shown here: ```{r shell commands, engine="sh"} wc -wlmc en_US.blogs.txt ``` I am not sure whether this is even being evaluated, as there is no…
Nicole Goebel
  • 537
  • 1
  • 9
  • 17
0
votes
1 answer

How to Implement a single program in C that replicates the following Unix command(s): ps -ef | grep YOUR_USER_id | wc

My teacher gave us a practice assignment for studying in my Operating Systems class. The assignment was to pipe three processes together and implement the commands in the title all at once. We are only allowed to use these commands when implementing…
ANIME4154142
  • 3
  • 2
  • 5
0
votes
3 answers

Calling linux utilities with options from within a Bash script

This is my first Bash script so forgive me if this question is trivial. I need to count the number of files within a specified directory $HOME/.junk. I thought this would be simple and assumed the following would work: numfiles= find $HOME/.junk…
Kyle Van Koevering
  • 169
  • 1
  • 3
  • 10
0
votes
2 answers

Why echo splits long lines in 80 chars when printing within quotes? (And how to fix it?)

Echoing without quotes... 1 line. Fine. $ echo $(ls -1dmb /bin/*) > test $ wc -l test 1 test Echoing with quotes... 396 lines. Bad. $ echo "$(ls -1dmb /bin/*)" > test $ wc -l test 396 test The problem comes when using echo for writing a file and…
Yajo
  • 5,808
  • 2
  • 30
  • 34
0
votes
0 answers

Minix 3 Number of processes

I'm working in a Unix-Like Kernel called Minix 3. I am having some trouble creating a function within the kernel that will allow me to output the number of processes being run. This is my code I have so far: PUBLIC void numproc_dmp() { …
Gamme40
  • 33
  • 6
0
votes
2 answers

List all files with file count as one of the output columns in $BASH?

Is there a way to show files similarly to ls -al that would also also show the file count of the directories listed? Sort of like an ls -al with ls -1 | wc -l as the final column? I've tried switching arguments out, and have pretty much given up on…
sos12
  • 699
  • 1
  • 6
  • 10
0
votes
2 answers

Select "europe" from df

my df2: League freq 18 England 108 27 Italy 79 20 Germany 74 43 Spain 64 19 France 49 39 Russia 34 31 Mexico 27 47 Turkey 24 32 Netherlands 23 37 Portugal …
Teletubbi-OS X
  • 391
  • 1
  • 3
  • 13
0
votes
1 answer

show a specific line from a command output Linux script shell

I want to find the file with the biggest number of words in a directory so I tried to use just the second line from the output of this command : wc * -w | sort -nr In fact I know that it will work if i saved the output to a file and used the…
Hamzaoui
  • 3
  • 1
0
votes
3 answers

How can I count the characters in STDIN using perl without wc?

I am attempting to write a script to count the number of lines, words, and characters input by the user in STDIN. Using the script below, I can accomplish this when a user inputs a file as a CLI, but when I attempt to use this code for STDIN, I end…
dff
  • 311
  • 2
  • 17
0
votes
0 answers

how to use ls, wc and > file

Ok. So here is the situation. I scan to an ftp folder. I want to know if new files have appeared in that folder using the following program code. The number of lines output to count.txt is 3, the reason being one of the files is .ftpquota. so if I…
0
votes
1 answer

Accessing files in the shell script

i am trying to access file email.txt in the script (directory of .txt file and the script is same) !#bin/bash total="$(wc -l < email.txt | tr -d ' ')" echo "$total" it's showing permission denied. Thankyou for any help
user2831683
  • 967
  • 1
  • 10
  • 21
0
votes
2 answers

Script to monitor any modifications in files in my FTP site

Iam trying to build a script to monitor any modifications in files in my FTP site. The script is given below. I have used wc -l to count the no. of files in the directory and have defined the constant value of files if there is going to be any…
Sathish
  • 1,245
  • 2
  • 15
  • 22
0
votes
2 answers

how to match between two strings stdin using grep?

I have 2 expressions I want to compare between them so I wrote: result=(`echo "${strings[0]}" | grep -i -w "${strings[1]}" | wc -w`) but when I echo result its empty... why? the.. more code: #!/bin/bash function checkStrings { strings=$* …
user3036061
  • 87
  • 2
  • 9