Output path for file from search file

Hello Everyone,

I am new to Unix and trying to learn as much as I can. But I do not need to create urgent scripts that I can use instantly. :(:frowning:

One of the scripts I am trying to write is essentially something that takes in a .txt file with product names.

The product names are looked up in various directories and folders to find the file with .xls extension and outputting the full extension path against each of the input file.

e.g: The input file : Beer_names.txt (consisting of various names of beers), for this I will take Duos .

It looks up throughout the directories and folders to find the Duos.xls file and outputs the exact location of the file.

In this case the output could be something like:

sgfs/beer_strength/2041343_newmalt/Brewer_3422E23/05012017_rensn/Results/Duos.xls

As of now I have to individually search and locate each of the locations and copy the file paths. Can this be made as script???

Thank you,
un007

Yes. But, with any request for assistance it always helps to know what operating system and shell you're using, and with a request like this knowing:

  1. what separates product names from each other in your input files,
  2. how your script will be given the name(s) of your input file(s),
  3. how to determine where to look for the .xls files corresponding to a given input file, and
  4. to where you want to copy the pathnames of those .xls files

would seem to be crucial to solving your problem.

Hello,

Sorry for the oversight. I am using Linux x86_64 2.6.32-431.29.2.el6.x86_64 GNU/Linux

I have provided additional information as requested.

The product names are saved as "tab delimited" file all file names will be in the first column under the header product_names.
The product names will be provided to the script using the tab delimited file from a folder named "product_analysis".
Where to look for each of the product will be provided in the script. The file directory is made up of different folders and hence the script after the first 2 folders will have to start scanning each of the folder till it finds the product names.
For e.g: Duos.xls is found in a folder in a parent directory: "sgfs". The actual location of the file required as output after search should be sgfs/beer_strength/2041343_newmalt_Brewer_3422E23/05012017_rensn/Results/Duos.xls. In this result output "sgfs" is the parent directory through which the search needs to be carried out. The parent directory can have upto 15 sub-directories and the search needs to be carried out through each of them.
The output format can be tab delimited file or a .xls file consisting of the query product name "Duos.xls" and with the complete path name to the file listing all the folders.

Please let me know if further information can be provided that will help.

Regards,
UN007

Sorry for the delay in responding...

I repeat: What shell are you using?

Great. And what are the names of the files that contain the filenames?

And how many lines are in the header in each of these files?

And where is the directory product_analysis located? (I.e., what is its absolute pathname or what is its relative pathname from the current working directory in which you will invoke your script?)

And where is the directory sgfs located?

All of this would be much easier if you would show us (in CODE tags) samples of your input files along with a clear description of the format of those input files and a sample of the output that should be produced from those sample input files.

Showing us (again in CODE tags) what you have tried to do to solve this problem on your own would help both you and us.