Reading a file in C shell | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Reading a file in C shell

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 10-10-2008
paruthiveeran paruthiveeran is offline
Registered User
 
Join Date: Jun 2008
Last Activity: 7 May 2010, 10:26 AM EDT
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Reading a file in C shell

I recently started working in c shell and I am embarassed to say I can't get a single read using while command to work

while read line
do
print $line
done < list.txt

Can somebody help. I need a solution specific to C shell.


The error I get is "while: Expression Syntax."
Sponsored Links
    #2  
Old 10-11-2008
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
who?
 
Join Date: Dec 2003
Last Activity: 16 April 2014, 11:09 PM EDT
Location: /dev/ph
Posts: 4,711
Thanks: 54
Thanked 411 Times in 382 Posts
One way ....

Code:
foreach line (`cat list.txt`)
    echo $line
end

Sponsored Links
    #3  
Old 10-12-2008
paruthiveeran paruthiveeran is offline
Registered User
 
Join Date: Jun 2008
Last Activity: 7 May 2010, 10:26 AM EDT
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks. It worked.
    #4  
Old 11-05-2008
pappu.cannt.dan pappu.cannt.dan is offline
Registered User
 
Join Date: Nov 2008
Last Activity: 6 November 2008, 5:16 AM EST
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Reading a file line by line, is not working with your solution.
E.g
Text file :
A = 34
B = 34
C = 45

I am looking for a solution for this problem.

Thanks
Pappu
(Foddalo &bull; Foddalo)
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
AWK/Shell script for reading text file suddhasatwa_bha Shell Programming and Scripting 7 01-25-2012 02:54 AM
Reading a property file through shell script??? sukhdip Shell Programming and Scripting 7 10-05-2011 08:30 AM
file reading through shell script Dip Shell Programming and Scripting 4 10-21-2008 10:10 PM
Reading data from a file through shell script Dip Shell Programming and Scripting 2 10-20-2008 12:51 PM
Reading file names from a file and executing the relative file from shell script anushilrai Shell Programming and Scripting 4 03-10-2006 04:25 AM



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