NOT able to pickup files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting NOT able to pickup files
# 1  
Old 05-19-2011
NOT able to pickup files

Hi,

I have two files to pick and excute these ones.

File1SmilieOLFIN.PRL_100.OIB.TLU.001.D20110510.T144948
File2SmilieOLFIN.PRM_100.OTU.001.D20100726.T050026


date '+%H:%M:%S'

SCRIPTS_PATH=/u/dolfin/bin
. ${SCRIPTS_PATH}/set_dolfin_env.sh
DATA_FILE_NAME=DATA_FILE
DATE_FORMAT=`date '+%Y%m%d'`
DATE_FORMAT=20110323
cd ${DOLFIN_IN_DIR}
# Try to get a data file matching the pattern and check if the data file exists or not

SAP_DATA_FILE=`ls DOLFIN.PR*_100*.001.D*.T* | egrep -e 'TLU|OTU'`
if [ ! -z "${SAP_DATA_FILE}" ]
then
echo "Found SAP data file ${SAP_DATA_FILE}"
cd ${DOLFIN_BIN_DIR}
i=0
for file in /u/dolfin/in/DOLFIN.PR*_100*.001.D*.T* | egrep -e 'TLU'
do
let i=i+1
SQL Load all the sap data from SAP_TUR into data management tables
sqlldr ${ORA_USER}/${ORA_PASSWD} control= /u/dolfin/bin/load_sap_credit_template.ctl bad=/u/dolfin/log/ data=$file
#move the processed data file to in_arc directory
mv $file ../in_arc
# Compress the data file
compress ../in_arc/$file
# echo $file archived
echo "Finished loading SAP data from TURKEY"
done
else
echo "No SAP data found for TURKEY!!!"
fi
date '+%H:%M:%S'



But getting error as

"load_sap_credit_data_oib_turkeynew1.sh[29]: syntax error at line 35 : `|' unexpected"

Reason is in the code
" for file in /u/dolfin/in/DOLFIN.PR*_100*.001.D*.T* | egrep -e 'TLU' "

This is invalid.

Could you please let us know replacing correct stmt in place of above code.

Appricate early response on this
# 2  
Old 05-19-2011
Hi,

Try something like this:
Code:
for file in $(ls -1 /u/dolfin/in/DOLFIN.PR*_100*.001.D*.T* | egrep -e 'TLU')

Regards,
Birei
# 3  
Old 05-19-2011
Pleas use code tags.

What shell are you using?
In bash, the correct syntax is:
Code:
for file in /u/dolfin/in/DOLFIN.PR*_100*.001.D*.T* ; do
   echo $file |  egrep -e 'TLU' 
   # do something else with $file
done

If you are trying to apply the grep filter on filenames, then
Code:
for file in `ls /u/dolfin/in/DOLFIN.PR*_100*.001.D*.T* |  egrep -e 'TLU' ` ; do
   echo $file 
   # do something else with $file
done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Automate splitting of files , scp files as each split completes and combine files on target server

i use the split command to split a one terabyte backup file into 10 chunks of 100 GB each. The files are split one after the other. While the files is being split, I will like to scp the files one after the other as soon as the previous one completes, from server A to Server B. Then on server B ,... (2 Replies)
Discussion started by: malaika
2 Replies

2. Shell Programming and Scripting

Need help for automated pickup of file based on a priority

Hi experts, I am facing a problem right now.I have to automate the pickup of files based on a priority.The scenario is as below: 1) There will be files from Mon-Fri with Mon file being named as abc_def_01_YYYYMMDD and Tue file being abc_def_02_YYYYMMDD and so forth till Friday's file which... (1 Reply)
Discussion started by: vikramgk9
1 Replies

3. Shell Programming and Scripting

How to create zip/gz/tar files for if the files are older than particular days in UNIX or Linux?

I need a script file for backup (zip or tar or gz) of old log files in our unix server (causing the space problem). Could you please help me to create the zip or gz files for each log files in current directory and sub-directories also? I found one command which is to create gz file for the... (4 Replies)
Discussion started by: Mallikgm
4 Replies

4. Shell Programming and Scripting

Need an automated pre-defined file pickup method

Hi Gurus, I need to develop a script which picks the files in a pre-defined order. The files from monday-friday will be named as abc_01_20130923 as monday's file and abc_02_20130924 as tuesday's..so..so forth till friday's which will be named as abc_05_20130927.It repeats over for the... (3 Replies)
Discussion started by: vikramgk9
3 Replies

5. UNIX for Dummies Questions & Answers

write a program in c in unix that display the files(includ sub-direc and files within) in a sorted

the sorting is based on name of file, file size modification time stamps o f file it should dislay the output in the following format "." and ".." enteries should be ignored please give some idea how to do it (1 Reply)
Discussion started by: pappu kumar jha
1 Replies

6. Shell Programming and Scripting

How to extract data from indexed files (ISAM files) maintained in an unix server.

Hi, Could someone please assist on a quick way of How to extract data from indexed files (ISAM files) maintained in an UNIX(AIX) server.The file data needs to be extracted in flat text file or CSV or excel format . Usually we have programs in microfocus COBOL to extract data, but would like... (2 Replies)
Discussion started by: devina
2 Replies

7. Shell Programming and Scripting

How to retrieve all the linked script files/ctl files/sql files?

Hi I am going to migrate our datawarehouse system from HP Tru 64 Unix to the Red Hat Linux. Inside the box, it is running around 40 cron jobs; inside each cron job, it is calling other shell script files, and the shell script files may again call other shell script files or ctl files(for... (1 Reply)
Discussion started by: franksubramania
1 Replies

8. UNIX for Dummies Questions & Answers

pickup files.

How can I pickup files with a specific date by "ls" command without options? (1 Reply)
Discussion started by: gd2003
1 Replies

9. Shell Programming and Scripting

pickup until last friday files from directory

Freinds, I need help: I need to process number of flat files on weekly basis. My source dir will receive flat files regulary at mid night between 1:00am and 6:00am. When I run my weekly file process it should get only the files which are until last friday (including friday)and move them in... (1 Reply)
Discussion started by: magi
1 Replies

10. Shell Programming and Scripting

pickup file from folder

Hi, Can any body help me,How to pickup file from folder using shellscript. FolderName:/test FileinFolder: test.txt MY req is:Shellscript pickup file from folder and pass file as parameter to java program..? Thanks, Rams (0 Replies)
Discussion started by: ram2s2001
0 Replies
Login or Register to Ask a Question