Output path for file from search file

Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Output path for file from search file
# 1  
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. SmilieSmilie

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:
Code:
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
Moderator's Comments:
Mod Comment Please use CODE tags when displaying sample input, sample output, and code segments.

Last edited by Don Cragun; 05-01-2017 at 10:38 PM..
# 2  
Quote:
Originally Posted by UN007
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. SmilieSmilie

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:
Code:
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
Moderator's Comments:
Mod Comment Please use CODE tags when displaying sample input, sample output, and code segments.
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.
# 3  
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
# 4  
Quote:
Originally Posted by UN007
Hello,

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

I repeat: What shell are you using?
Quote:
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".
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?)
Quote:
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.
And where is the directory sgfs located?
Quote:
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
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.
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #45
Difficulty: Easy
IEEE 802.11 specifies bluetooth networks.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Search of multiple numeric entries in an output file

Hello Tech Guys, I have two files named check.txt and output.txt Content of check.txt 620070527336551 40201800027285 620070551928314 40201800027285 620070534376312 40201800027285 620070536668046 02711306140261 620070248491123 02711306140261 620070553851296 02711306140261... (4 Replies)
Discussion started by: Xtreme
4 Replies

2. Shell Programming and Scripting

Read in search strings from text file, search for string in second text file and output to CSV

Hi guys, I have a text file named file1.txt that is formatted like this: 001 , ID , 20000 002 , Name , Brandon 003 , Phone_Number , 616-234-1999 004 , SSNumber , 234-23-234 005 , Model , Toyota 007 , Engine ,V8 008 , GPS , OFF and I have file2.txt formatted like this: ... (2 Replies)
Discussion started by: An0mander
2 Replies

3. Shell Programming and Scripting

Search for a word in file and output to another

Hello Experts! I am trying to perform a common task, searching data from within a file and placing what is found into another.However, I have not been able to figure the “How to” with this situation. I need to search through all lines within this text and pull the first positional attributes... (5 Replies)
Discussion started by: leepet
5 Replies

4. Shell Programming and Scripting

Recursive file processing from a path and printing output in a file

Hi All, The script below read the path and searches for the directories/subdirectories and for the files. If files are found in the sub directories then read the content of the all files and put the content in csv(comma delimted) format and the call the write to xml function to write the std... (1 Reply)
Discussion started by: Optimus81
1 Replies

5. Shell Programming and Scripting

How to search/replace a directory path in a file using perl

Hello All, Here is what I am trying to do and maybe you guys can point me in the right direction. I have a file that contains the following string(s): WARNING: </d1/test/program1> did not find item1 WARNING: </d1/test/program1> item1 does not exist WARNING: </d1/test/program2> item1 failed... (1 Reply)
Discussion started by: maxshop
1 Replies

6. Shell Programming and Scripting

Using awk to when reading a file to search and output to file

Hi, I am not sure if this will work or not. I am getting a syntax error. I am reading fileA, using an acct number field trying to see if it exists in fileB and output to new file. Can anyone tell me if what I am doing will work or should I attempt it another way? Thanks. exec < "${fileA}... (4 Replies)
Discussion started by: ski
4 Replies

7. Shell Programming and Scripting

Trouble with a file path as awk output in for loop

When I run the following command in the shell it works fine. It prints a city name and then a path for a file. ~$ for i in `awk -F':' '{print $0}' /home/knoppix/Desktop/data/subs | grep -m 1 $ city | sed "s/:/ /"` >do >echo $i >done Now, when I place it in this shell script (sh) it prints... (6 Replies)
Discussion started by: afroCluster
6 Replies

8. Shell Programming and Scripting

Search and find the string and output to a new file.

Hi I want to search the following in the entire file and put them in a diff file. file 1 contains : Non error probabilities are not decreasing in curve 1GEORGE_SGD_SUB Mid Point RESCAP_SGD_SNU curve have errors Non default probabilities are not decreasing in curve ABF_JPY_SUB Mid Point... (3 Replies)
Discussion started by: szchmaltz
3 Replies

9. Shell Programming and Scripting

Input file redirect in output path and want name as inputfilename_new.txt

not required this time (6 Replies)
Discussion started by: Sandeep_Malik
6 Replies

10. Shell Programming and Scripting

awk script to search an html file and output links

hello. i want to make an awk script to search an html file and output all the links (e.g .html, .htm, .jpg, .doc, .pdf, etc..) inside it. also, i want the links that will be output to be split into 3 groups (separated by an empty line), the first group with links to other webpages (.html .htm etc),... (8 Replies)
Discussion started by: kyris
8 Replies

Featured Tech Videos