Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shell Scripting

Status
Not open for further replies.

nareshbabu

Programmer
Joined
Feb 13, 2003
Messages
2
Location
US
Hi,

I have a script where a variable has multiple lines.
How can i count the no. of lines in it in a script.

Ex: PIDS="1234
2345
3455"

PIDCNT=??????


Thanks
 
PIDCNT=`echo ${PIDS} | wc -l` vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Once you put the contents in a variable are you sure they are still individual lines? Maybe the newlines have been lost in the translation and all you have are just words

PIDCNT=`echo ${PIDS} | wc -w`

just a thought.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top