VectorLinux
October 24, 2014, 06:25:16 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Visit our home page for VL info. To search the old message board go to http://vectorlinux.com/forum1. The first VL forum is temporarily offline until we can find a host for it. Thanks for your patience.
 
Now powered by KnowledgeDex.
   Home   Help Search Login Register  
Please support VectorLinux!
Pages: [1]
  Print  
Author Topic: counting lines in files  (Read 1414 times)
Daniel
Packager
Vectorian
****
Posts: 704


WWW
« on: July 22, 2009, 04: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: 2288


« Reply #1 on: July 22, 2009, 10: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


WWW
« Reply #2 on: July 23, 2009, 01: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


WWW
« 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?
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: 1856


« 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
Logged
Daniel
Packager
Vectorian
****
Posts: 704


WWW
« 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?
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: 2288


« Reply #6 on: July 24, 2009, 02:07:27 pm »

You use "let" like this:

Code:
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: 1856


« Reply #7 on: July 24, 2009, 03:16:49 pm »

http://www.codecoffee.com/tipsforlinux/articles2/044.html

Bigpaws
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!