LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-12-2008, 12:42 AM   #1
Swapna173
LQ Newbie
 
Registered: Dec 2007
Posts: 25

Rep: Reputation: 15
search for File


Hi Guys,

I have a US_MFg_Units_On_Hand_Actual_2008_08_F.dat file where the file suffix changes everytime depending on the month and year. Now, i have a ctl file named US_MFg_Units_On_Hand_Actual.ctl for the same. Now depending on the .dat file i need to search for the corresponding .ctl file of it.

I was trying it will sql query but was not able to
select dsdas_table_name from configuration_master where source_file_name like '
select lower(substr('US_MFg_Units_On_Hand_Actual_2008_08_F',0,23)) from dual;

since here i am not able to know where to insert % sign to get the .ctl file name which is stored in database as well as in the linux machine.

So i thought there might be some way in linux to get the same.

Swapna
 
Old 08-12-2008, 01:10 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Are you trying to see if the ctl file is in the DB?
Sounds like Oracle, in which case, iirc the SQL is (similar to this)

select 1
from configuration_master
where source_file_name = 'US_MFg_Units_On_Hand_Actual.ctl';

If you get NULL, the rec is not there.

In Linux you can check the disk:

Code:
var=`ls US_MFg_Units_On_Hand_Actual.ctl 2>/dev/null|wc -l`
if [[ $var -eq 0 ]]
then
    echo "$file exists"
else
    echo "Nope"
fi
 
Old 08-12-2008, 01:22 AM   #3
Swapna173
LQ Newbie
 
Registered: Dec 2007
Posts: 25

Original Poster
Rep: Reputation: 15
Hi Chris,

My Question is to get the <<somefile>>.ctl depending on the <<somefile_suffix>>.dat. It is sure that i will have .ctl file. I need to get the .ctl on the basis of .dat file and the problem is my dat file name has suffix. but not my ctl file. I am having more than 1 ctl and dat files in the same folder.

I need to search "US_MFg_Units_On_Hand_Actual.ctl" file name from the folder when I have "US_MFg_Units_On_Hand_Actual_2008_08_F.dat" file.

Swapna
 
Old 08-12-2008, 02:11 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
just to clarify, in Unix filename terms,

'US_MFg_Units_On_Hand_Actual' is the filename, 'ctl' is the suffix
'US_MFg_Units_On_Hand_Actual_2008_08_F' is filename, 'dat' is the suffix

anyway:
Code:
>s="US_MFg_Units_On_Hand_Actual_2008_08_F.dat"
>v=${s:0:27}
>echo $v
US_MFg_Units_On_Hand_Actual

>c=${v}.ctl
>echo $c
US_MFg_Units_On_Hand_Actual.ctl
See http://tldp.org/LDP/abs/html/string-manipulation.html
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to read string in 1 file and search in another file? ameyapandit Programming 7 07-11-2008 12:05 PM
how to search a file JUbuntu Linux - Newbie 7 03-20-2008 06:55 AM
Search for File corley Linux - General 2 08-04-2004 08:40 PM
Find File broken, need search utility, where does WineX install, KDE file roller? Ohmn Mandriva 6 07-05-2004 10:34 PM
How to 'apt-cache search' & 'apt-file search' by distribution? davidas Debian 3 04-19-2004 01:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration