VectorLinux

Please login or register.

Login with username, password and session length
Advanced search  

News:

Visit our home page for VL info. For support and documentation, visit the Vector Linux Knowledge Center or search the Knowledge Center and this Forum using the search box above.

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

Daniel

  • Packager
  • Vectorian
  • ****
  • Posts: 704
    • TuxToys - Packages for VectorLinux 6.0
counting lines in files
« on: July 22, 2009, 05:54:04 pm »

Is there a command that counts how many lines there are in a file?
Logged
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: 2305
Re: counting lines in files
« Reply #1 on: July 22, 2009, 11:09:56 pm »

wc -l <filename>
Logged
"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, 02:38:25 pm »

Thanks!
Logged
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, 09: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?
Logged
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: 1869
Re: counting lines in files
« Reply #4 on: July 24, 2009, 10:49:04 am »

wc -l "filename here remove brackets too" | awk '{print $1}'

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

Bigpaws
Logged

Daniel

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

Thanks.

Another question: How do I add, multiply, subtract, and divide numbers/(numbers in variables) in a shell script?
Logged
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: 2305
Re: counting lines in files
« Reply #6 on: July 24, 2009, 03: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
Logged
"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: 1869
Re: counting lines in files
« Reply #7 on: July 24, 2009, 04:16:49 pm »

Logged