1826212 Members
2494 Online
109691 Solutions
New Discussion

scripting help

 
SOLVED
Go to solution
roadrunner_1
Regular Advisor

scripting help

I am running the sysinfo script to generate the output in html format. I have automated a task in windows machine where it ftps to the unix boxes and grabs the sysinfo files to the web server directory so that these can viewed as a webpage.
Now that my mainpage has links to various system names, I need the sysinfo file to renamed to a standard file name so that the links work fine...
Here is what I am trying to do.
1. When sysinfo is run i get the following three files in the tmp directory
sysinfo_hpux_20020114
sysinfo_hpux_20020114.index
sysinfo_hpux_20020114.main
Assuming that this directory contains only the above three files. I need to do this..
2. Each time after the output is done, I need to rename the veryfirst file as sysinfo_hpux ..in otherwords i need to remove the datestamp from the file name.

can anyone help me do this..
9 REPLIES 9
F. X. de Montgolfier
Valued Contributor

Re: scripting help

Hi,

a very simple _untested_ (no access to a machine today) script:

#! /usr/bin/ksh
cp sysinfo_hpux_[:digit:](\8\).index sysinfo_hpux.index
cp sysinfo_hpux_[:digit:](\8\).main sysinfo_hpux.main
cp sysinfo_hpux_[:digit:](\8\) sysinfo_hpux

Cheers,

FiX
James R. Ferguson
Acclaimed Contributor
Solution

Re: scripting help

Hi:

# sed -e 's/_[0-9]\{8\}//'

For example:

echo sysinfo_hpux_20020114.main|sed -e 's/_[0-9]\{8\}//'

..returns "sysinfo_hpux.main"

Regards!

...JRF...
roadrunner_1
Regular Advisor

Re: scripting help

i tried running one command..but it gives syntax error
sh: Syntax error: `(' is not expected.
James R. Ferguson
Acclaimed Contributor

Re: scripting help

Hi (again):

If you captured the filename in a variable, 'X' then you can do this:

# mv $X `echo $X|sed -e 's/_[0-9]\{8\}//`

Regards!

...JRF...
roadrunner_1
Regular Advisor

Re: scripting help

jeff,
thanks..it worked..but how do I do a listing which should display only the files names one after the other in a single column..it should not display permission, uid, gid date stamp etc..
James R. Ferguson
Acclaimed Contributor

Re: scripting help

hi (again):

# ls -l x1 #...that's a numeric "one" after the "x" columns.

Regards!

...JRF...
roadrunner_1
Regular Advisor

Re: scripting help

Jeff,

Did u mean ls -x1??
ls -l x1 tries looks for a file x1 ;)
James R. Ferguson
Acclaimed Contributor

Re: scripting help

Hi (again):

Yes, sorry, I meant:

# ls -x1 /tmp

Regards (...and I am JRF...)
roadrunner_1
Regular Advisor

Re: scripting help

sorry..I meant James aka JRF..was on the phone talking to some one..and type his name..
AND YOU ARE JRF.. ;)