Help required for cat command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help required for cat command
# 1  
Old 11-23-2006
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  
Old 11-23-2006
Code:
for i in `cat temp`

# 3  
Old 11-23-2006
This is the output i am getting

$ ./list.ksh
valiue is : cat temp
# 4  
Old 11-23-2006
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
# 5  
Old 11-23-2006
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 Smilie Smilie
# 6  
Old 11-23-2006
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`

# 7  
Old 11-23-2006
Bug

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

Thanks all for the immediate reply.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Help need on cat command

I have two files as below 1.txt AA 123 CC 145 DD 567 2.txt AA 111 YY 128 CC 144 FF 222 DD 777 ZZ 875 basically 1.txt is updated file, if i do cat 1.txt 2.txt output should be as below o/p (4 Replies)
Discussion started by: Tecnical_help12
4 Replies

2. Shell Programming and Scripting

Help need on cat command

I have two files as below 1.txt AA 123 CC 145 DD 567 2.txt AA 111 YY 128 CC 144 FF 222 DD 777 ZZ 875 basically 1.txt is updated file, if i do cat 1.txt 2.txt output should be as below o/p (2 Replies)
Discussion started by: Tecnical_help12
2 Replies

3. AIX

cat command

Hi. How can i write a command on AIX like the one i did at linux that find string in a file and show me that string, and return 3 lines before and 4 lines after that string. my linux command is: /bin/cat <filename> | tail -150 | grep -B2 -A8 "<string to look for>" Example: /bin/cat ... (10 Replies)
Discussion started by: yechi_r
10 Replies

4. Shell Programming and Scripting

Cat command help

I want to concatenate 100 files to one file and append file name in each record to find out which file it came from for a in $(<shal_group) do cat $a >> bigoutput.group The above code put all files in one file but i want file name appended to each file Record should be like this... (3 Replies)
Discussion started by: pinnacle
3 Replies

5. UNIX for Advanced & Expert Users

cat command

I believe I used the cat command to append a file beside another file (instead of below it) but I did not document it any where and I can't remember exactly how I did it. Has anyone else done this? I have tried all the cat options individually with no luck. It may be a combination of options. ... (2 Replies)
Discussion started by: nickg
2 Replies

6. Shell Programming and Scripting

cat in the command line doesn't match cat in the script

Hello, So I sorted my file as I was supposed to: sort -n -r -k 2 -k 1 file1 | uniq > file2 and when I wrote > cat file2 in the command line, I got what I was expecting, but in the script itself ... sort -n -r -k 2 -k 1 averages | uniq > temp cat file2 It wrote a whole... (21 Replies)
Discussion started by: shira
21 Replies

7. Cybersecurity

Help Required: Command to find IP address and command executed of a user

Hi, I am trying to write a script which would figure out who has run which command and their IP. As i dont have any clue as to which commands would do this job, i request some gurus to help me on this. Thanks Vishwas (2 Replies)
Discussion started by: loggedout
2 Replies

8. UNIX for Advanced & Expert Users

cat command

Dear All I have two text files File1.txt and File2.txt . I am concatenating the two files and making it as single file Cat_File.txt. Now i need to keep joined file in two different path. that is I need to use cat command only once ,but store joined file in two different locations. Since... (3 Replies)
Discussion started by: tkbharani
3 Replies

9. UNIX for Dummies Questions & Answers

Difference between cat , cat > , cat >> and touch !!!

Hi Can anybody tell the difference between Difference between cat , cat > , cat >> and touch command in UNIX? Thanks (6 Replies)
Discussion started by: skyineyes
6 Replies

10. UNIX for Dummies Questions & Answers

CAT command

All - how do i save the file after i used CAT command line to modify? Thanks :confused: (2 Replies)
Discussion started by: March_2007
2 Replies
Login or Register to Ask a Question