Skip to main content
[Edit removed during grace period]
Source Link
Cleaned up wording and formatting.
Source Link

script Script that outputs the total amountnumber of lines in all the text files that are passed as arguments

So I'm working on a script that will passaccept arguments that are text files, and I should output the total amountnumber of lines in those files. Like  For example, if I say

./myScript file1 file2 file3 

it will print

10 total

10 total 

(let us assume that the sum of all the lines from those three files is 10).

I know how to go over all the arguments, I.  I also know that, to get the amountnumber of lines in a file, I would say:

wc -l < fileName 

However, how can I make that into an "int" that I can add to some sort of cumulative sum? Thanks friends

script that outputs the total amount of lines in all the text files that are passed as arguments

So I'm working on a script that will pass arguments that are text files, and I should output the total amount of lines . Like if I say

./myScript file1 file2 file3 

it will print

10 total

(let us assume that the sum of all the lines from those three files is 10)

I know how to go over all the arguments, I also know that to get the amount of lines in a file, I would say:

wc -l < fileName 

However how can I make that into an "int" that I can add to some sort of cumulative sum? Thanks friends

Script that outputs the total number of lines in all the text files that are passed as arguments

So I'm working on a script that will accept arguments that are text files, and should output the total number of lines in those files.  For example, if I say

./myScript file1 file2 file3 

it will print

10 total 

(let us assume that the sum of all the lines from those three files is 10).

I know how to go over all the arguments.  I also know that, to get the number of lines in a file, I would say:

wc -l < fileName 

However, how can I make that into an "int" that I can add to some sort of cumulative sum?

Source Link
Haz
  • 63
  • 1
  • 5

script that outputs the total amount of lines in all the text files that are passed as arguments

So I'm working on a script that will pass arguments that are text files, and I should output the total amount of lines . Like if I say

./myScript file1 file2 file3 

it will print

10 total

(let us assume that the sum of all the lines from those three files is 10)

I know how to go over all the arguments, I also know that to get the amount of lines in a file, I would say:

wc -l < fileName 

However how can I make that into an "int" that I can add to some sort of cumulative sum? Thanks friends