Help with retreiving files' information stored in different directories.


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Help with retreiving files' information stored in different directories.
# 1  
Old 04-07-2011
CPU & Memory Help with retreiving files' information stored in different directories.

Dear All,
I have a question.
I have similarly named files stored in different directories and I'd like to retreive information from them remotely to perform other tasks. For example given:
Code:
Folder 5 has files S5_SK1.chr01        S5_SK1.chr02         .......
Folder 6 has files S6_SK1.chr01        S6_SK1.chr02         .......
Folder 7 has files S7_SK1.chr01        S7_SK1.chr02         .......
Folder 8 has files S8_SK1.chr01        S8_SK1.chr02         .......

I'd like to concatenate all *chr01 files in different folders as one file , *chr02 files in different folders as one file and so on ...
Can someone suggest how to acheive this sort of task ?
I'll appreciate your feedback
Cheers and hv a nice daySmilie
# 2  
Old 04-07-2011
If you are searching in the current working directory:
Code:
 find . -iname *.chr01 | sed "s;^.;`pwd`;"

For concatenation, you don't have to use sed as you don't have to print the full path:
Code:
find . -iname *.chr01 | cat

# 3  
Old 04-08-2011
@Gaurab:

I am not searching in the current working directory for these files ... these Files are located in other directories as I mentioned ...infact in different folders/directories but I want to extract info from them remotely without having to copy or move them all to the working directory ... so lets say I want to concatenate all 4 files present in different folders, and all ending with chr01 but starting with S5 or S6 or S7 or S8 (thats why they are in different folders) is there a way to do that ?
Cheers Smilie

---------- Post updated at 10:01 AM ---------- Previous update was at 02:56 AM ----------

Any ideas on my initial query ??

Can someone suggest me because being a beginner I dont know if its possible to do this with Unix or Perl.

Appreciate your response Smilie

Cheers n hv a nice day
# 4  
Old 04-08-2011
Quote:
Originally Posted by pawannoel
@Gaurab:

I am not searching in the current working directory for these files ... these Files are located in other directories as I mentioned ...infact in different folders/directories but I want to extract info from them remotely without having to copy or move them all to the working directory ... so lets say I want to concatenate all 4 files present in different folders, and all ending with chr01 but starting with S5 or S6 or S7 or S8 (thats why they are in different folders) is there a way to do that ?
Cheers Smilie
The code I posted will work if you just go to the top most directory and run it. It will read through all the sudirectories (the -r option for ls).

Let me know if you still have any trouble.
-G
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Archiving and moving files into directories, creating directories, etc.

how can i move "dataName".sql.gz into a folder called 'database' and then move "$fileName".tar.gz * .htaccess into a folder called 'www' with the entire gzipped file being "$fileName".tar.gz? Is this doable or overly complex. so mydemo--2015-03-23-1500.tar.gz > database -... (5 Replies)
Discussion started by: wyclef
5 Replies

2. Shell Programming and Scripting

Rename the files in all the directories and sub-directories

Hi all, I have more than 12000 files in 46 different directories and each directory has 2 sub-directories named “dat” or “gridded”. Dat sub-directories have files with extension “jpg.dat” and gridded sub-directories have files with extension “.jpg”. I need to... (1 Reply)
Discussion started by: AshwaniSharma09
1 Replies

3. Shell Programming and Scripting

Retreiving multiple files by changing a parameter with one program

Hi all, I am using following command: perl program.pl input.txt output.txt CUTOFF 3 > groups_3.txt containing program.pl, two files (input.txt, output.txt) and getting output in groups_3.txt: But, I wish to have 30 files corresponding to each CUTOFF ranging from 0 to 30 using the same... (1 Reply)
Discussion started by: bioinfo
1 Replies

4. Shell Programming and Scripting

How to list all the files, directories and sub-directories in the current path except one directory?

Can anyone come up with a unix command that lists all the files, directories and sub-directories in the current directory except a folder called log.? Thank you in advance. (7 Replies)
Discussion started by: Manjunath B
7 Replies

5. UNIX for Dummies Questions & Answers

Shell Scripts - Show all directories with full information ( and no files)

Hello all, i'm stumped.... I need to list all directories with all there info and exclude the files, then vice versa. I am not sure if I need to string several ls commands together or how to even do that. I believe I need to do some variation of ls -l but need to figure out how to take out the... (5 Replies)
Discussion started by: citizencro
5 Replies

6. Shell Programming and Scripting

How to store files/directories in different directories!!

Hi legends, I am writing a script, in that my requirement is, if all the fill types stored in one directory from that we need to separate different different directories based on the file types. for example in a directory(anish). 5 different types files 1- directory 2- .txt files 2- .sh... (1 Reply)
Discussion started by: anishkumarv
1 Replies

7. UNIX for Dummies Questions & Answers

List directories and sub directories recursively excluding files

Hi, Please help me, how to get all the direcotries, its sub directories and its sub directories recursively, need to exclude all the files in the process. I wanted to disply using a unix command all the directories recursively excluding files. I tried 'ls -FR' but that display files as... (3 Replies)
Discussion started by: pointers
3 Replies

8. Shell Programming and Scripting

Retreiving information from a text file

Hey guys, i just started shell programming and i have a question. I am working on a simple inventory project and one of the problems which i am unable to solve would be how i am going to extract the data i need from a text file(which will be my database) and then put it inside the executable to be... (5 Replies)
Discussion started by: gregarion
5 Replies

9. HP-UX

To save the bdf information on all mounted directories

Hi, I want to write a script to save all the bdf information (disk usage) on all mounted directories in a file. Then I want to compare saved bdf info to current system within 5%. Please help me on this. I am using HP-UX. Actually there is data center move and I need to run the script before... (12 Replies)
Discussion started by: adityam
12 Replies
Login or Register to Ask a Question