LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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, 01: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, 03: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 05:31 AM
parsing files using gtk shandy^^^ Programming 0 01-26-2006 10:02 AM
Parsing config files unholy Programming 5 09-18-2004 03:59 PM
Help Parsing Log files blacky777 Linux - Security 6 04-21-2004 01:06 PM
parsing log files jstu Linux - General 4 06-10-2003 07:26 PM

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

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