Please support VectorLinux!

Author Topic: counting lines in files  (Read 1611 times)

Daniel

  • Packager
  • Vectorian
  • ****
  • Posts: 704
    • TuxToys - Packages for VectorLinux 6.0
counting lines in files
« on: July 22, 2009, 04:54:04 pm »
Is there a command that counts how many lines there are in a file?
The following sentence is true. The previous sentence is false.

VL 6.0 SOHO KDE-Classic on 2.3 Ghz Dual-core AMD with 3 Gigs of RAM

rbistolfi

  • Packager
  • Vectorian
  • ****
  • Posts: 2299
Re: counting lines in files
« Reply #1 on: July 22, 2009, 10:09:56 pm »
wc -l <filename>
"There is a concept which corrupts and upsets all others. I refer not to Evil, whose limited realm is that of ethics; I refer to the infinite."
Jorge Luis Borges, Avatars of the Tortoise.

--
Jumalauta!!

Daniel

  • Packager
  • Vectorian
  • ****
  • Posts: 704
    • TuxToys - Packages for VectorLinux 6.0
Re: counting lines in files
« Reply #2 on: July 23, 2009, 01:38:25 pm »
Thanks!
The following sentence is true. The previous sentence is false.

VL 6.0 SOHO KDE-Classic on 2.3 Ghz Dual-core AMD with 3 Gigs of RAM

Daniel

  • Packager
  • Vectorian
  • ****
  • Posts: 704
    • TuxToys - Packages for VectorLinux 6.0
Re: counting lines in files
« Reply #3 on: July 24, 2009, 08:52:20 am »
Follow-up question: How do I get the wc -l <file> command to return only the number of lines, not the number of lines and the name of the input file?

Semi-related question: What command returns the size of a file?
The following sentence is true. The previous sentence is false.

VL 6.0 SOHO KDE-Classic on 2.3 Ghz Dual-core AMD with 3 Gigs of RAM

bigpaws

  • Vectorian
  • ****
  • Posts: 1868
Re: counting lines in files
« Reply #4 on: July 24, 2009, 09:49:04 am »
wc -l "filename here remove brackets too" | awk '{print $1}'

ls -l "file name here, remove brackets too"

Bigpaws

Daniel

  • Packager
  • Vectorian
  • ****
  • Posts: 704
    • TuxToys - Packages for VectorLinux 6.0
Re: counting lines in files
« Reply #5 on: July 24, 2009, 01:51:26 pm »
Thanks.

Another question: How do I add, multiply, subtract, and divide numbers/(numbers in variables) in a shell script?
The following sentence is true. The previous sentence is false.

VL 6.0 SOHO KDE-Classic on 2.3 Ghz Dual-core AMD with 3 Gigs of RAM

rbistolfi

  • Packager
  • Vectorian
  • ****
  • Posts: 2299
Re: counting lines in files
« Reply #6 on: July 24, 2009, 02:07:27 pm »
You use "let" like this:

Code: [Select]
rbistolfi@vector1 [ ~ ] %let a=3+2
rbistolfi@vector1 [ ~ ] %echo $a
5
rbistolfi@vector1 [ ~ ] %let b=$a+1
rbistolfi@vector1 [ ~ ] %echo $b
6
"There is a concept which corrupts and upsets all others. I refer not to Evil, whose limited realm is that of ethics; I refer to the infinite."
Jorge Luis Borges, Avatars of the Tortoise.

--
Jumalauta!!

bigpaws

  • Vectorian
  • ****
  • Posts: 1868
Re: counting lines in files
« Reply #7 on: July 24, 2009, 03:16:49 pm »