I am in the process of writing my first script using Bash and not sure where to go from here and wondered if you could help a bit�. I am trying to go through Connect Direct files and search for a specific date (20090714) and type (CEC,CEP,CEM) to pull out of the file. If it is archived I need to check the directory to see if it is a zipped file (history files named like this: STATARCH-20090714-20090714.Z ) unzip the file and rename to normal name (like this: a S20090721.081) and then tie into the piece explained above. Any input would be grateful!
show us what you've tried so far and where you've problems...
What are/is "Connect Direct files"? What have you done so far?
#!/bin/bash
clear
echo "Please enter the date for CD info wanted: \c"
read rrd_date
echo "Please enter CEC CEM or CEP: \c"
read file_name
sleep 2
# Create the output file with CEC CEP or CEM information
echo "Creating $file_name file"
cd /opt/cdunix/work/vcndm
sleep 2
grep $file_name S2*$rrd_date.* >~/rrd$rrd_date$file_name
echo "output rrd$rrd_date$file_name file created"
sleep 2
FILE=~/rrd$rrd_date$file_name
echo $FILE
FS="|"
while read line
do
# store field 1
F1=$(echo $line | cut -d$FS -f1)
echo "$F1" >>~/cdrrdout$rrd_date$file_name
# store field 2
F2=$(echo $line | cut -d$FS -f2)
echo "$F2" >>~/cdrrdout$rrd_date$file_name
# store field 18
F18=$(echo $line | cut -d$FS -f18)
echo "$F18" >>~/cdrrdout$rrd_date$file_name
# store field 19
F19=$(echo $line | cut -d$FS -f19)
echo "$F19" >>~/cdrrdout$rrd_date$file_name
echo " " >>~/cdrrdout$rrd_date$file_name
done < $FILE
echo "cdrrdout$rrd_date$file_name has been created"
This part works... just not sure how to incorporate if the file was archived (zipped) into this process.
Thanks!
---------- Post updated at 08:49 AM ---------- Previous update was at 08:47 AM ----------
Connect Direct/NDM file transmissions
Next time use CODE-tags when posting code, data or logs to enhance readability and to preserve foramtting like indention etc., ty.
---------- Post updated at 09:40 AM ---------- Previous update was at 08:49 AM ----------
was also wondering if egrep would be better to use instead of grep when looking at the file?
guess no one wants to help me......
you can check the file extention by using..
echo ${file_name##*.}