linux-admin.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Find command in shell script
@ 2002-06-18  2:24 Rowan Eppelstun
  2002-06-18  5:19 ` rDNS blocked Kilaru Sambaiah
  2002-06-18  6:57 ` Find command in shell script Camelia NASTASE
  0 siblings, 2 replies; 6+ messages in thread
From: Rowan Eppelstun @ 2002-06-18  2:24 UTC (permalink / raw)
  To: linux-admin

Hi,

I am trying to do the following command in a script but cannot seem to get
the escape characters right for the find - exec mv command.

I am trying to move all files named 200206*.pdf to a subdirectory of their
currnet directory called "jun". Once I get the syntax correct for this I
will automate it for the year, but have got stuck at this bit.

Could anyone please advise what I am missing.
----------------------------------------------------------------------------
-------------
#!/bin/sh

MONTH='date +%m'
DATE='date +%Y%m'
DIR=/home/rowan/eod/2002/ba

if DATE=200206; then FILENAME="'200206*.pdf'"
fi

if MONTH=06 ; then MONDIR=$DIR/jun/
fi

cd $DIR

pwd

find ./ -name $FILENAME -exec mv -f '{}' $MONDIR ';'

exit 0
----------------------------------------------------------------------------
------------------

Thanks in advance.


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


^ permalink raw reply	[flat|nested] 6+ messages in thread
* RE: Find command in shell script
@ 2002-06-18 11:19 johnjulian1
  2002-06-18 12:18 ` John Hallam
  0 siblings, 1 reply; 6+ messages in thread
From: johnjulian1 @ 2002-06-18 11:19 UTC (permalink / raw)
  To: "Rowan Eppelstun", linux-admin

remove the double quotes from FILENAME="'200206*.pdg'"
remove the single quotes from '{}'
remove the single quotes from ';' and preceed the ; with \   ie \;

"Rowan Eppelstun" <reppelstun@yahoo.com.au> wrote:

>Hi,
>
>I am trying to do the following command in a script but cannot seem to get
>the escape characters right for the find - exec mv command.
>
>I am trying to move all files named 200206*.pdf to a subdirectory of their
>currnet directory called "jun". Once I get the syntax correct for this I
>will automate it for the year, but have got stuck at this bit.
>
>Could anyone please advise what I am missing.
>----------------------------------------------------------------------------
>-------------
>#!/bin/sh
>
>MONTH='date +%m'
>DATE='date +%Y%m'
>DIR=/home/rowan/eod/2002/ba
>
>if DATE=200206; then FILENAME="'200206*.pdf'"
>fi
>
>if MONTH=06 ; then MONDIR=$DIR/jun/
>fi
>
>cd $DIR
>
>pwd
>
>find ./ -name $FILENAME -exec mv -f '{}' $MONDIR ';'
>
>exit 0
>----------------------------------------------------------------------------
>------------------
>
>Thanks in advance.
>
>
>_________________________________________________________
>Do You Yahoo!?
>Get your free @yahoo.com address at http://mail.yahoo.com
>
>-
>To unsubscribe from this list: send the line "unsubscribe linux-admin" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html
>


__________________________________________________________________
Your favorite stores, helpful shopping tools and great gift ideas. Experience the convenience of buying online with Shop@Netscape! http://shopnow.netscape.com/

Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-06-18 12:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-06-18  2:24 Find command in shell script Rowan Eppelstun
2002-06-18  5:19 ` rDNS blocked Kilaru Sambaiah
2002-06-18  6:57 ` Find command in shell script Camelia NASTASE
  -- strict thread matches above, loose matches on Subject: below --
2002-06-18 11:19 johnjulian1
2002-06-18 12:18 ` John Hallam
2002-06-18 12:29   ` John Hallam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).