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
|