Finding files with the name of the results of another search


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Finding files with the name of the results of another search
# 1  
Old 09-23-2014
Finding files with the name of the results of another search

Dear All,
I have a file with this name= xx-nnnn.csv , I has texts in this format,
Code:
231048975938093056;234317862284705793;609384034;14955353;1344700706000;1;
231048975938093056;234317958632054785;715450794;52422878;1344700729000;1;
231048975938093056;234317958632054785;715450794;14955353;1344700729000;1;
231048975938093056;234318551647924227;32599342;52422878;1344700870000;1;
231048975938093056;234319048949780482;252168241;14955353;1344700989000;2;

now I want to take take all the second fields as the search parameter, and find the files with files names containing this

for example all the files with *234317862284705793*.csv or *234317958632054785.csv

Thank u in advance.

best,
David

Last edited by Don Cragun; 09-23-2014 at 03:43 AM.. Reason: Add CODE and ICODE tags.
# 2  
Old 09-23-2014
Quote:
Originally Posted by davidfreed
Dear All,
I have a file with this name= xx-nnnn.csv , I has texts in this format,
Code:
231048975938093056;234317862284705793;609384034;14955353;1344700706000;1;
231048975938093056;234317958632054785;715450794;52422878;1344700729000;1;
231048975938093056;234317958632054785;715450794;14955353;1344700729000;1;
231048975938093056;234318551647924227;32599342;52422878;1344700870000;1;
231048975938093056;234319048949780482;252168241;14955353;1344700989000;2;

now I want to take take all the second fields as the search parameter, and find the files with files names containing this

for example all the files with *234317862284705793*.csv or *234317958632054785.csv

Thank u in advance.

best,
David
Is the file named xx-nnnn.csv in the same directory as the files with names like *234317862284705793*.csv and *234317958632054785.csv? Why do you need an asterisk after the numbers found in the 2nd field in xx-nnnn.csv for the data on the 1st line of the file, but do not need one for the data on the 2nd and 3rd lines in the file? Why is the data on other lines in that file ignored?

After you find the names, what do you want to do with them?
This User Gave Thanks to Don Cragun For This Post:
# 3  
Old 09-23-2014
Thank you so much,
yes in the same directory, we just assume * , actually all the files have the same pattern, important is to have these numbers containing in the file name.
it is for every line, it was just an example.
just show the file names.thank u so much
# 4  
Old 09-23-2014
What is the environment?
This User Gave Thanks to Cochise For This Post:
# 5  
Old 09-23-2014
Ubuntu 14, 64bit , Terminal
# 6  
Old 09-23-2014
You could try something like:
Code:
#!/bin/ksh
while IFS=";" read junk x junk
do      ls -1 *$x*.csv 2> /dev/null
done < xx-nnnn.csv

The ls command option is the digit one; not the lower case letter ell.

In addition to working with ksh, this will also work with any other shell that accepts basic Bourne shell syntax.
This User Gave Thanks to Don Cragun For This Post:
# 7  
Old 10-03-2014
Thank you so much, but it doesnt work.
To test, I inserted the filename of one of the files in another file and tested as below:

Code:
#!/bin/ksh
while IFS=";" read junk x junk
do ls -1 *$x*.csv 2> /dev/null
done < cascs-233250026925740032.csv

there is no output.

now in cascs-233250026925740032.csv , we have one line with the filename of another file in this dir.

Last edited by Don Cragun; 10-03-2014 at 02:37 PM.. Reason: Add CODE and ICODE tags.
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. What is on Your Mind?

Search Results (Search, New, and Today's Topics) Animation Switch

Hey, I added an animation switch on the search results page; so by default the thread previews are off, but if you want to look at them, just click on the green button and the thread previews will turn on (and back off). See image and attached animation: ... (1 Reply)
Discussion started by: Neo
1 Replies

2. Shell Programming and Scripting

Finding files with wc -l results = 1 then moving the files to another folder

Hi guys can you please help me with a script to find files with one row/1 line of content then move the file to another directory my script below runs but nothing happens to the files....Alternatively Ca I get a script to find the *.csv files with "wc -1" results = 1 then create a list of those... (5 Replies)
Discussion started by: Dj Moi
5 Replies

3. Shell Programming and Scripting

Can ctag and cscope support recording search results and displaying the history results ?

Hello , When using vim, can ctag and cscope support recording search results and displaying the history results ? Once I jump to one tag, I can use :tnext to jump to next tag, but how can I display the preview search result? (0 Replies)
Discussion started by: 915086731
0 Replies

4. Shell Programming and Scripting

Search for Files and clear line after results

Hi, this is a little strange, i have the following code: if then echo -e "psa/admin/sbin present " which shows if a directory is present, but what I would like it to do is show the line and then remove its self and show the rest of the script... no idea what to look... (1 Reply)
Discussion started by: foz
1 Replies

5. Shell Programming and Scripting

AWK - no search results

Hi all, I'm new to awk and I'm experiencing syntax error that I don't know how to resolve. Hopefully some experts in this forum can help me out. I created an awk file that look like this: $ cat myawk.awk BEGIN { VAR1=PATTERN1 VAR2=PATTERN2 } /VAR1/ { flag=1 } /VAR2/ { flag=0 } {... (7 Replies)
Discussion started by: hk18
7 Replies

6. Shell Programming and Scripting

Operations on search results

Hi, I am a newbie at Unix scritping, and I have a question. Looking at the search functionality on Unix. Here I have a structure root---------dir1 ------- file1, file2, file3 |_____dir2 ______file1@, file4 |_____dir3_______file1@, file5 Under root directory, I... (4 Replies)
Discussion started by: nj302
4 Replies
Login or Register to Ask a Question