LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-18-2007, 08:32 AM   #1
nirmaltom
Member
 
Registered: Jun 2005
Location: India
Distribution: Redhat,Fedora,DSL,Ubuntu
Posts: 238

Rep: Reputation: 30
Cool csh


hi,
I want to write a basic original csh , not tcsh(since using solaris) to count the no of files in a directory and print whether they are > or = or < than 1
i am new to csh.
Where i am wrong?How to store the result of ls -1 | wc -l in files variable?

Quote:
#!/usr/bin/csh
files= ( ls -1 | wc -l )

if [ $files < 1] then
echo "No of files less than 1"
else if [ $files == 1 ] then
echo "No of files equal to 1"
else if [ $files > 1 ]then
echo "No of files greater than 1"
endif
thanks for any response.
regards,
nirmal Tom.
 
Old 05-18-2007, 09:07 AM   #2
nirmaltom
Member
 
Registered: Jun 2005
Location: India
Distribution: Redhat,Fedora,DSL,Ubuntu
Posts: 238

Original Poster
Rep: Reputation: 30
hi,
got it, i was wrong at
Quote:
files= ( ls -1 | wc -l )
replaced it by
Quote:
setenv files `ls -1 | wc -l`
setenv used to set environmental variables, isnt it?
any elegant way to deal with it?
regards,
Nirmal Tom.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
help with quotes in csh kanesee Programming 1 05-08-2007 08:10 PM
csh script stellafrank Linux - Newbie 3 11-15-2006 07:11 PM
csh script help vijraj Linux - Newbie 2 10-04-2006 08:49 AM
New to Solaris/csh slick_willie Solaris / OpenSolaris 19 12-04-2004 03:47 PM
csh zaza Linux - Newbie 6 05-21-2002 07:26 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration