The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help Required: Command to find IP address and command executed of a user loggedout Security 2 08-06-2008 08:12 PM
Help Required regarding wc command dtidke Shell Programming and Scripting 7 06-05-2008 06:38 AM
Sed-- command help required pssandeep UNIX for Dummies Questions & Answers 6 03-18-2008 10:43 AM
Help required using cut command mahalakshmi Shell Programming and Scripting 4 03-18-2008 06:36 AM
Help required on AWK command udiptya UNIX for Dummies Questions & Answers 13 01-22-2008 08:43 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-23-2006
mahalakshmi mahalakshmi is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 38
Help required for cat command

Hi,
I had written the following script to find the list of files with *.ksh in a directory. and store it in a temp file.

I want to loop through the file temp and list the contents. I had used cat temp. But its giving Cat and temp as the output.

Do help me out.

Thanks


find . -name '*.ksh' -print > temp

for i in cat temp

do
echo 'valiue is ': $i
done
  #2 (permalink)  
Old 11-23-2006
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,952
Code:
for i in `cat temp`
  #3 (permalink)  
Old 11-23-2006
mahalakshmi mahalakshmi is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 38
This is the output i am getting

$ ./list.ksh
valiue is : cat temp
  #4 (permalink)  
Old 11-23-2006
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,952
Code:
>cat temp
a
b
c
Code:
for i in `cat list`
do
echo 'value is' : $i
done
value is : a
value is : b
value is : c

check the contents of temp file after find command is run
  #5 (permalink)  
Old 11-23-2006
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Quote:
Originally Posted by mahalakshmi
This is the output i am getting

$ ./list.ksh
valiue is : cat temp
use backticks
Code:
for i in `cat temp`
  #6 (permalink)  
Old 11-23-2006
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Code:
while read i
do
echo 'value is ': $i
done < temp
or

Code:
for i in `cat temp`
do
echo 'value is ': $i
done
The first code is faster
  #7 (permalink)  
Old 11-23-2006
mahalakshmi mahalakshmi is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 38
Smile

Thanks anbu the while loop is working not the for loop.

Thanks all for the immediate reply.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:55 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0