Reading a file in C shell


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Reading a file in C shell
# 1  
Old 10-10-2008
Reading a file in C shell

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

Code:
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."

Last edited by rbatte1; 01-26-2017 at 06:17 AM..
# 2  
Old 10-11-2008
One way ....
Code:
foreach line (`cat list.txt`)
    echo $line
end

# 3  
Old 10-12-2008
Thanks. It worked.
# 4  
Old 11-05-2008
Reading a file line by line, is not working with your solution.
E.g
Text file :
Code:
A = 34
B = 34
C = 45

I am looking for a solution for this problem.

Thanks
Pappu
(Foddalo &bull; Foddalo)

Last edited by rbatte1; 01-26-2017 at 06:18 AM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Reading XML file and print the values in the text file using Linux shell script

hi guys, i want help... Reding XML file and print the values into the text file using linux shell script file as per below xml file <sequence> <Filename>aldorzum.doc</Filename> <DivisionCode>US</DivisionCode> <ContentType>Template</ContentType> <ProductCode>VIMZIM</ProductCode> </sequence>... (1 Reply)
Discussion started by: sravanreddy
1 Replies

2. Shell Programming and Scripting

Shell script reading file slow

I have shell program as below #!/bin/sh echo ======= LogManageri start ========== #This directory is getting the raw data from remote server Raw_data=/opt/ftplogs # This directory is ready for process the data Processing_dir=/opt/processing_dir # This directory is prcoessed files and... (4 Replies)
Discussion started by: Chenchireddy
4 Replies

3. UNIX for Dummies Questions & Answers

C-Shell script help reading from txt file

I need to write a C-Shell script with these properties: It should accept two arguments on the command line. The first argument is the name of a file which contains a list of names, and the second argument is the name of a directory. For each file in the directory, the script should print the... (1 Reply)
Discussion started by: cerce
1 Replies

4. Shell Programming and Scripting

reading the values from a file in C Shell for loop

Hi All, I need small help on for loop syntax in C shell. How can we read the values from a file (line by line) through C shell loop. For Ex: $Cat file1 data1 data2 data3 data4 $ I have to print those values in a variable and have to perform some steps... Can anyone help on... (2 Replies)
Discussion started by: raghu.iv85
2 Replies

5. Shell Programming and Scripting

Error while reading from a file in shell script

Hi All, I'm writing a script to read a file line by line and then perform awk function on it. I am getting an error . My file has one name in it "James". I'm expecting my o/p to be youareJamesbond James ./users.sh: line 7: =: command not found #script to read file line by line #adding... (5 Replies)
Discussion started by: Irishboy24
5 Replies

6. Shell Programming and Scripting

Reading the Properties File From Shell script

Hi, I am new to the shell script please I need help for following question. I have properties file name called "com.test.properties" I have No of key values in this properties. com.person.name = xyz com.person.age = 55 com.person.address = hello I want read this properties but i... (1 Reply)
Discussion started by: venukjs
1 Replies

7. Shell Programming and Scripting

File reading problem via shell script

Hi, Data file named parameter contains : DB=y Alter_def.sql Create_abc.sql SQL=y database.sql my_data.sql To read this file I use var_sql=$(awk -F= '$1 == "SQL" { print $2 }' parameter.txt) if then sql_f_name=`grep "\.sql" parameter.txt` echo $sql_f_name fi (2 Replies)
Discussion started by: Dip
2 Replies

8. Shell Programming and Scripting

file reading through shell script

For reading a file through shell script I am using yhe code : while read line do echo $line done<data.txt It reads all the line of that file data.txt. Content of data.txt looks like: code=y sql=y total no of sql files=4 a.sql b.sql c.sql d.sql cpp=n c=y total no of c files=1 (4 Replies)
Discussion started by: Dip
4 Replies

9. Shell Programming and Scripting

Reading file names from a file and executing the relative file from shell script

Hi How can i dynamically read files names from a list file and execute them from a single shell script. Please help its urgent Thanks in Advance (4 Replies)
Discussion started by: anushilrai
4 Replies
Login or Register to Ask a Question