The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
help needed in variable assignment gander_ss Shell Programming and Scripting 2 05-11-2007 03:13 AM
Variable assignment in shell scripting jaiganeshbe Shell Programming and Scripting 2 02-28-2007 02:48 AM
awk variable assignment in a file pondlife Shell Programming and Scripting 4 01-12-2006 04:54 AM
variable assignment in new shell maverick80 Shell Programming and Scripting 7 09-03-2005 12:38 AM
@ in a variable assignment rkap UNIX for Dummies Questions & Answers 1 05-23-2005 11:53 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-22-2006
DDD DDD is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 2
Variable assignment question

Hello,

I would like to assign number of lines in a file to a variable (to be passed later as an argument to a function). I am doing it like this:

numLines=wc -l < file.txt

which gives an error. Could somebody help?
  #2 (permalink)  
Old 09-22-2006
Glenn Arndt's Avatar
Glenn Arndt Glenn Arndt is offline Forum Advisor  
Anomalous Lurker
  
 

Join Date: Feb 2006
Location: Indianapolis, IN
Posts: 255

Code:
numLines=$(wc -l < file.txt)

Or if using sh, do
Code:
numLines=`wc -l < file.txt`

  #3 (permalink)  
Old 09-22-2006
DDD DDD is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 2
Thanks!!! It works!
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:15 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0