The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 05-27-2009
coolrekz coolrekz is offline
Registered User
  
 

Join Date: May 2009
Posts: 3
Post Omitting the last 2 alphabets in the words

Hi Guys,

Bit new to Unix shell scripting so this question might seems little kiddish for you.

what im trying to achieve here is :

I have file which is compressed like Account_52320090605076_log.Z

so in my shell script i call this file also as one of my parameters

like

./Information.sh DBNAME USERNAME DIREC_LOC Account_52320090605076_log.Z

what i need here is

1. Check if the file has a .Z or .z at its end .
if yes then
uncompress it

after uncompress the DUMPFILE_NAME should have a new paramater without the .Z extension

2. If no then proceed with the next step


my script looks like this

#!/bin/ksh

DB_NAME=$1
USER_NAME=$2
DIR_LOC=$3
DUMPFILE_NAME=$4
LINE=$DUMPFILE_NAME; export LINE
VAR=`echo $LINE |awk -F. '{print $3}`;export VAR
echo $VAR


if [ "$VAR" = "z" ] || [ "$VAR" = "Z" ]
then

uncompress $DUMPFILE_NAME

chmod 744 `echo $LINE |awk -F. '{print $1"."$2}'`

DUMPFILE_NAME=$LINE |awk -F. '{print $1"."$2}' ; export DUMPFILE_NAME

echo $DUMPFILE_NAME

fi

echo $DUMPFILE_NAME


but it seems like lines doesn't fetch me the correct result , could some one help and let me know a correct command that i can use for this situation.

thx
rekz