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 ISSUE - URGENT

Re: UNIX SCRIPT ISSUE - URGENT

From: Larry Strickland <stricklandl_at_voyager.spjc.cc.fl.us>
Date: Wed, 25 Jul 2001 07:44:53 -0700
Message-ID: <F001.003546F2.20010725064712@fatcity.com>

Since you have so many files, you are likely to hit problems with the line length of the various shells. Assuming that all of the files are in the directory "/usr/myfiles" and that the script mentioned below is named "cvtip", is executable and is in /usr/local/bin (or some other directory in the path), you could do the following:

$ cd /usr/myfiles
$ find . -type f -print | xargs cvtip

and that would do exactly what you want IF you modify the scipt as follows (this processes multiple files at the same invocation of the script):

#!/usr/bin/ksh
for FN
do

    IP=`echo $FN|cut -c1-16`
    mv $FN ${FN}.old
    sed "s/Report by Hosts/$IP| Report by Hosts/" <${FN}.old >$FN done

This modification processes multiple filenames on the command line. It also assumes that the file exists in the current directory (which I don't like, but which I don't want to work around right now). It first renames the file by tacking .old on the filename, then converts it as the previous script did and sends the output to the original filename (i.e., without the .old on the end)

Hope this helps,
larry

On Wed, 25 Jul 2001 06:26:12 -0800
"Johan Muller" <bad_dba_at_yahoo.com> wrote:

> I need to extract the first 16 bytes of a filename (AIX 4.3) which consists of
> an IP address (nnn.nnn.nnn.nnn), and move that to first 16 positions in the
> file itself, plus adding a pipe (|) sign for a delimiter, and save the IP
> address as a file name with a .dat extension, before loading the contents into
> a table.
>
> My predecessor concocted the following:
>
> #!/usr/bin/ksh
> FN=$1
> IP=`echo $FN|cut -c1-16`
> sed "s/Report by Hosts/$IP| Report by Hosts/" $FN > newfile.dat
> #-- End of file
>
> which is great for a single file at a time.
>
> Right now I have to perform this surgery on 19 986 files, which is in one
> place.
> Using the script above would take me over 20 000 hours.
>
> Any way I can grab the files one at the time based on a ls command, and invoke
> the script, and to end up when the last file has been processed.
>
> ALTERNATIVE:
>
> Each file contains the IP address which has to move into the first position
> after a string on line 13 which you guessed it: is called 'IP Address:'. Is
> their a way vi could be used to achieve the same result?
>
> Any input would be appreciated,
>
>
> Johan Muller
>
> __________________________________________________
> Do You Yahoo!?
> Make international calls for as low as $.04/minute with Yahoo! Messenger
> http://phonecard.yahoo.com/
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> --
> Author: Johan Muller
> INET: bad_dba_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).

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Larry Strickland
  INET: stricklandl_at_voyager.spjc.cc.fl.us

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).
Received on Wed Jul 25 2001 - 09:44:53 CDT

Original text of this message

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