LinuxQuestions.org
Help answer threads with 0 replies.
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, 01: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, 02:10 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
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, 02: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, 03:11 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 01:05 PM
how to search a file JUbuntu Linux - Newbie 7 03-20-2008 07:55 AM
Search for File corley Linux - General 2 08-04-2004 09:40 PM
Find File broken, need search utility, where does WineX install, KDE file roller? Ohmn Mandriva 6 07-05-2004 11:34 PM
How to 'apt-cache search' & 'apt-file search' by distribution? davidas Debian 3 04-19-2004 02:56 PM


All times are GMT -5. The time now is 02:30 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration