LinuxQuestions.org
Visit Jeremy's Blog.
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 10-24-2007, 02:12 PM   #1
onacorpuscle
LQ Newbie
 
Registered: Mar 2006
Location: Barcelona
Distribution: SUSE LINUX 9.3
Posts: 10

Rep: Reputation: 0
Help Parsing Files With Find


Hello collegues

I have a problem when parsing files. I'm writing a (handler )shell like these:
# Profile and parameter App file
. /usr/.profile
. /usr/app/Proteus/config.txt
# Path of Working dirs.
LOGFILE=$PROT_HOME/$PROT_LOG
PATH_IN=$XTRN_HOME/$PROT_PATH_IN
PATH_OUT=$PROT_HOME/$PROT_PATH_OUT
PATH_BIN=$PROT_HOME/$PROT_PATH_EXE
PROC_TYP=$PROT_PRC_MOD
`date +"%d/%m/%y %H:%M:%S # prcProteus.sh # PROTEUS # Initailizing ">>$LOGFILE`
...
# Searching files to process
FILES=`find $PATH_IN -type f -name "*.$PROT_IN_FILE_TYPE" | cut -f1 -d .`
...
Where $PROT_IN_FILE_TYPE is the file extension, txt for example.
The results of FILES variable is like this:
data/in/CANCEL_20071020
data/in/LOAD_20071019
data/in/LOAD_20071020
...
I need to cut the "data/in" expression dinamically. I atempt with awk like this:
awk '{print(substr($1,length($1)-position of last "/"+1,length($1)-(length($1)-position of last "/"+1)))}'| sort

In sql is very easy with the "instr" command...

Any suggestions?

Thanks a lot!

Xavier
 
Old 10-25-2007, 04:56 AM   #2
onacorpuscle
LQ Newbie
 
Registered: Mar 2006
Location: Barcelona
Distribution: SUSE LINUX 9.3
Posts: 10

Original Poster
Rep: Reputation: 0
Hi

I resolve it, with a different approach, by using "ls - l" rather than "find".
Previous approach:
...
# Searching files to process
#FILES=`find $PATH_IN -type f -name "*.$PROT_IN_FILE_TYPE" | cut -f1 -d .`
...
New approach:
...
# Searching files to process
cd $PATH_IN
FILES=ls -l *.$PROT_IN_FILE_TYPE | cut -c57- | cut -f1 -s -d.

Very simple, but efficient.

Bye!

Xavier
 
  


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
perl files download instead of parsed on apache2 mod-perl2 not parsing perl files zeigerpuppy Debian 1 02-16-2006 06:31 AM
parsing files using gtk shandy^^^ Programming 0 01-26-2006 11:02 AM
Parsing config files unholy Programming 5 09-18-2004 04:59 PM
Help Parsing Log files blacky777 Linux - Security 6 04-21-2004 02:06 PM
parsing log files jstu Linux - General 4 06-10-2003 08:26 PM


All times are GMT -5. The time now is 04:23 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