Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Unix script newbie

Re: Unix script newbie

From: Cindy P Nathan <Cindy.P.Nathan_at_dupontpharma.com>
Date: 07 Nov 2000 14:55:51 -0500
Message-Id: <10673.121351@fatcity.com>


Sonia,
You can use the unix command 'cut' to extract part of strings.

So you can do something like:-

#extract the latter part of the filename where for eg ${file} = BUSH_xxxxxxxx assuming the filenames are <= 100 chars long
  suff_file=`echo $file | cut -c 6-100`
# Build the new filename

  newfil=${WVAR}${suff_fil}
#do the copy into the

  cp $file ${ WINDIR}/${newfil}

Hope this helps.
Cindy

	spajerowski_at_yahoo.com
	11/07/00 02:27 PM
		 
		 To: ORACLE-L_at_fatcity.com_at_SMTP
		 cc: (bcc: Cindy P Nathan/SWF/Pharma)
		 Subject: Unix script newbie

Hello Everyone,
I am newbie to unix. I am trying to write a script where all the files starting with BUSH_ will change to GORE_ or vice-versa (Depending upon the election results).
I am not sure what the format will be after BUSH_ or GORE_.
This is what I have

#!/bin/ksh

if [ $# -ne 2 ];
then
 echo "Error - Incorrect number of parameters passed"  exit 2
fi

LVAR=$1 (# will be passed BUSH_ or GORE_) WVAR=$2 (# will be passed BUSH_ or GORE_)

WINDIR='/export/home/oracle/scripts/WIN' LOSEDIR='/export/home/oracle/scripts/LOSE'

for file in $LVAR[*] # wild card does not work do
 if [ -f $file ];
 then

  #cp $WIG1DIR/$file $WIG2DIR/B_$file
  #copy all files starting with BUSH_xxxx to GORE_xxxx
  # where xxxx is rest of the string.

  echo "$file is backed up in $WINDIR"
 fi
done
I am not able to find any substring or mid function to strip the filename and append with the rest of the string.
Will really appreciate if some unix expert canhelp me out.

Thanks for your help.
Sonia P.



Do You Yahoo!?
Thousands of Stores. Millions of Products. All in one Place. http://shopping.yahoo.com/
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: sonia pajerowski
  INET: spajerowski_at_yahoo.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).



------------------------------

 From: Murugesan Balakrishnan <mail_oracle_at_yahoo.com>
 Date: Tue, 7 Nov 2000 11:56:37 -0800 (PST)
 Subject: Re: Query to select only the duplicate records from a table?

Thank you very much. I appreciate it.

Muru

--- bunyamin karadeniz <bunyamink_at_havelsan.com.tr>
wrote:
> SELECT interested_columns
> FROM table_name a
> WHERE rowid >(SELECT min(rowid)
> FROM table_name b
> WHERE b.pk_column = a.pk_column ) ;
> 
> *pk_coloumn is the primary key column the table.
> if you want to delete the duplicate rows, just
> change the select to DELETE
> 
> ****** if you want to leave only one row of the
> duplicated rows,For ex: you
> have 3 duplicated rows and want to delete 2 of them
> and leave only one, The
> only possibility as I understand is first selecting
> the duplicate rows with
> DISTINCT  and then insert into another table and
Received on Tue Nov 07 2000 - 13:55:51 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US