reading files from diractory one by one


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting reading files from diractory one by one
# 1  
Old 10-14-2008
Java reading files from diractory one by one

hi
i have directory (/tmp/Satya)that contains lots of files.
i need to get the no of files and read them one by one
please help


thanks in advance
Satya
# 2  
Old 10-14-2008
Code:
find /tmp/Satya -type f | \
while read filename 
do
       while read rec
       do
          echo "$rec"
       done < $filename
done

This reads each file line by line
# 3  
Old 10-14-2008
hi jim,
when i used the above the file name is coming as "/tmp/Satya/10.File" , but i want only 10.File,please help
# 4  
Old 10-14-2008
You can just add
Code:
basename $rec

Or you can modify the find command:
Code:
find /tmp/Satya -type f -printf "%f\n"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Need Help in reading N days files from a Directory & combining the files

Hi All, Request your expertise in tackling one requirement in my project,(i dont have much expertise in Shell Scripting). The requirement is as below, 1) We store the last run date of a process in a file. When the batch run the next time, it should read this file, get the last run date from... (1 Reply)
Discussion started by: dsfreddie
1 Replies

2. Shell Programming and Scripting

reading from 2 files using awk

hi, Is it possible to read and compare 2 files which have different Field separators at the same time using awk??? file1: 1,dayal,maruti,Z-234,bangalore,KA,........ 2,yash,esteem,Y-007,delhi,DL,........... . . . fill 2: Z-234|Registered|Bangalore Y-007|Registered|Bangalore . . . ... (2 Replies)
Discussion started by: VGR
2 Replies

3. Shell Programming and Scripting

Reading extension of files

Hi, I need a command to read extension of files. Could anyone please help me? (14 Replies)
Discussion started by: priyadarshini
14 Replies

4. Shell Programming and Scripting

reading multiple files

Hello I have a requirement where i have to loop through certain directory which will have multiple files. After looping through i have to make a list of file names exisitng in the directory and write them to a sequental file and each file should be delimited by ^%^ i.e If i have 3 files A,... (3 Replies)
Discussion started by: dsdev_123
3 Replies

5. Shell Programming and Scripting

Reading input files

Okay, so I've looked on here and found some similar things, but not exactly what I am looking for. I am working on creating a script that can back up some files, based on the contents of another file - the configuration file. First file contains the files to back up - we'll call this... (1 Reply)
Discussion started by: pdxwarrior
1 Replies

6. Shell Programming and Scripting

reading from 2 files through while loop

hi i have two files cat input.txt 123456| 43256 456482|5893242 cat data.txt xv 123456 abcd dsk sd 123456 afsfn dd df 43256 asdf ff ss 456482 aa sf 5893242 ff ff aa 5893242 aa aa i need to read inputs from input.txt and find data for data.txt. then i need to print them as a... (2 Replies)
Discussion started by: windows
2 Replies

7. Shell Programming and Scripting

reading two files

Hi, I have 2 files file 1 ---- 10013 This is a text 10014 This is a test 10015 This is a temp file 2 ---- 10013 010014737 ADSM 1300004 E 10014 020012323 ABCD 1718888 E 10015 030121212 ADSW 1290991 E need to compare column1 in... (2 Replies)
Discussion started by: injeti
2 Replies

8. Solaris

Reading Files In

I'm looking to write a script where i look in a file called files.txt. This file has a list of other files in there. I want the script to be able to look at this files.txt and go off and find the files that are listed in another directory. I am doing it this way as filenames change week in... (1 Reply)
Discussion started by: Pablo_beezo
1 Replies

9. UNIX for Dummies Questions & Answers

Reading Files

Hi I need to perform certain tests on information contained in a file, a lot of what is contained in the file is duplicate data, so what I want to do as it is a failrly substantial file size is to start and finish reading from a specifed line in the file. Can someone tell me how to indicate... (3 Replies)
Discussion started by: oop
3 Replies

10. Shell Programming and Scripting

reading gz files

Hi, I have a simple perl script where I am passing array of gziped files to the while loop and trying to read content of each field one line at the time using gzcat. Yet, I can not get it to work Here is what I am doing ... while ($filename=shift) { open(MYFILE, "| gzcat $filename"); ... (2 Replies)
Discussion started by: arushunter
2 Replies
Login or Register to Ask a Question