Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 May 1997 16:08:48 -0500 (CDT)
From:      "Lee Crites (AEI)" <leec@adam.adonai.net>
To:        RGireyev@bellind.com
Cc:        questions@FreeBSD.ORG
Subject:   Re: Gotta Date?
Message-ID:  <Pine.BSF.3.95.970509160057.23269E-100000@adam.adonai.net>
In-Reply-To: <97May9.120433pdt.17030-3@firewall.bellind.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 9 May 1997 RGireyev@bellind.com wrote:

=>
=>I am trying to rename a file by appending a curent
=>name to the end of it. For example if I have a file
=>called beavis I want to rename it to beavis.05091997
=>
=>Any ideas????

I use these three scripts.  If you like them, fine.  All of them are csh
scripts.  The first is called autofile.  It uses the other two, called
autodate and autotime, respectively.  If you pass it (autofile) a set of
arguments, it will create a file name with all of them as well.  So, the
script:
    #!/bin/csh -f
    set fname1 = `autofile beavis`
    set fname2 = `autofile hello there world`
    echo $fname1
    echo $fname2

will return:

    beavis.01Mar97.125345
    hello.there.world.01Mar97.125345

Clear as mud?  Good.

Lee


/scripts/autofile:
#!/bin/csh -f
#
# return a string with the autodate.autotime
#

# start off by building a string with all of the parms
  set part1 = ""
  if !($1 == "") then
    foreach parmin ( $* )
      if ("$part1" == "") then
        set part1 = $parmin
      else
        set part1 = $part1"."$parmin
      endif
      end
    set part1 = $part1"."
  endif

# get the autodate and autotime strings
  set part2 = `/scripts/autodate`"."`/scripts/autotime`

# show the whole thing
  echo $part1$part2


/scripts/autodate:
#!/bin/csh -f
#
# Description:
#    This will return today's date in my format
#
if !($1 == "") then
  echo -n $1"."
endif

date|awk '{printf("%02d%s%d",$3,$2,$6%100)}'


/scripts/autotime:
#!/bin/csh -f
#
# Description:
#    This will return today's date in my format
#
if !($1 == "") then
  echo -n $1"."
endif

date|awk '{split($4,a,":");printf("%s%s%s",a[1],a[2],a[3])}'




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.95.970509160057.23269E-100000>