What is wrong with the following code?

8 views
Skip to first unread message

Srinivas Janaswamy

unread,
Jun 9, 2014, 4:21:20 PM6/9/14
to unix-and-perl-...@googlegroups.com
#! /bin/sh

fname=names.dat

var=( cat $fname | we -l )
echo $var

Keith Bradnam

unread,
Jun 9, 2014, 5:11:08 PM6/9/14
to unix-and-perl-...@googlegroups.com
  1. Is this script producing any errors when you run it (this would be helpful to know)?
  2. What is the purpose of the script (this would also be helpful to know)?
  3. How are you running the script (this would also be helpful to know)?
  4. Is there a file named 'names.dat' in the directory where you run the script?
  5. Did you intend for there to be a space between the #! and the /bin/sh?

Srinivas Janaswamy

unread,
Jun 9, 2014, 8:16:37 PM6/9/14
to unix-and-perl-...@googlegroups.com
Thanks Keith, 
(1) Yep, the script is not giving me the value that I need to get.
(2) I am revising my programming skills
(3) In the Bourne shell, after creating the executable version through chmod operation
(4) names.dat file is available
(5) Yes, there is a space between #! and /bin/sh

Keith Bradnam

unread,
Jun 9, 2014, 11:49:01 PM6/9/14
to unix-and-perl-...@googlegroups.com
More specifically, what is the command that you are running, and what is the error message that you are seeing?

Mike Covington

unread,
Jun 10, 2014, 5:39:25 AM6/10/14
to unix-and-perl-...@googlegroups.com
Do you mean var=`wc -l $fname` instead of var=( cat $fname | we -l ) ?


On Monday, June 9, 2014 1:21:20 PM UTC-7, Srinivas Janaswamy wrote:
Reply all
Reply to author
Forward
0 new messages