shell pattern matching | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

shell pattern matching

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 09-15-2008
rakeshforum rakeshforum is offline
Registered User
 
Join Date: Sep 2008
Last Activity: 4 January 2009, 9:19 PM EST
Location: india
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Network shell pattern matching

Hello Members

I am facing a problem regarding pattern matching.please guide me to solve the issue.My requirement is like:
There is table in oracle database, in that table contain columns ,inside the column so many files are there. my requirement is that to search a pattern for example: pattern is "123456" . Write a shell script that search the pattern one by one file(i.e it takes the file one by one from table) . if inside a file pattern doesn't exist then it will redirect this pattern and file name to some other file.

Please give me some idea so that i can move ahead, any help will be highly appreciated.

Thanks
Rakesh

Last edited by rakeshforum; 09-15-2008 at 04:45 AM..
Sponsored Links
    #2  
Old 09-15-2008
rakeshforum rakeshforum is offline
Registered User
 
Join Date: Sep 2008
Last Activity: 4 January 2009, 9:19 PM EST
Location: india
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
please reply me soon
Sponsored Links
    #3  
Old 09-15-2008
indianjassi indianjassi is offline
Registered User
 
Join Date: Sep 2008
Last Activity: 22 June 2009, 11:08 AM EDT
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
First tell us what you have tried.

So that we can suggest you improvement..
    #4  
Old 09-15-2008
Franklin52's Avatar
Franklin52 Franklin52 is offline Forum Staff  
Moderator
 
Join Date: Feb 2007
Last Activity: 21 October 2014, 7:52 AM EDT
Location: The Netherlands
Posts: 7,719
Thanks: 123
Thanked 538 Times in 508 Posts
Quote:
Originally Posted by rakeshforum View Post
please reply me soon
Bump up questions is not allowed, please read our rules.
Sponsored Links
    #5  
Old 09-15-2008
Niroj Niroj is offline
Registered User
 
Join Date: Aug 2008
Last Activity: 23 July 2012, 4:01 PM EDT
Location: Bangalore, INDIA
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Plz try this one..

Hi Rakesh I didn't work in Oracle but I could suggest this way to try:
Please check it before running. I didn't check this program..
===========================
chk_file ()
{
echo "Enter the destination direcory nm: [Give the full path]"
read dest

for f in `cat $1`
do
if [ -f $f ] && [ ` grep "(pattern like:1234)" $f | wc -w ` != 1 ]; then

mv $f $dest

fi
done

}

# login to unix machine(check the instance)

echo "`dbaccess db_nm << EOFSQL 2>> /dev/null/
SELECT col_nm FROM Tab_nm;
EOFSQL`" > file_nms.tmp


chk_file file_nms.tmp
Sponsored Links
    #6  
Old 09-15-2008
Niroj Niroj is offline
Registered User
 
Join Date: Aug 2008
Last Activity: 23 July 2012, 4:01 PM EDT
Location: Bangalore, INDIA
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Plz try this...(FOR ORACLE)
chk_file ()
{
echo "Enter the destination direcory nm: [Give the full path]"
read dest

for f in $1
do
if [ -f $f ] && [ ` grep "(pattern like:1234)" $f | wc -w ` != 1 ]; then

mv $f $dest

fi
done

}

file_nm=`sqlplus -S usernm/passwd@host_string <<EOF
set head off feedback off echo off pages 0
SELECT col_nm FROM tab_nm`
/
EOF

chk_file file_nm

Last edited by Niroj; 09-15-2008 at 07:06 AM..
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
awk pattern matching and shell issue. deboprio Shell Programming and Scripting 7 12-28-2011 03:35 AM
Pattern matching in shell script Deei Shell Programming and Scripting 3 06-14-2010 05:05 AM
shell script pattern matching mirfan Shell Programming and Scripting 3 09-14-2009 02:22 AM
Pattern matching in shell scripting. Irishboy24 Shell Programming and Scripting 6 08-28-2009 09:45 AM
Pattern matching in a shell script? paulobrad Shell Programming and Scripting 1 07-14-2008 08:56 AM



All times are GMT -4. The time now is 07:56 PM.