[PLUG] Copying From Multiple Source Directories to a Destination Directory
Fred James
fredjame at fredjame.cnc.net
Mon Jun 14 03:46:52 UTC 2010
Russell Johnson wrote:
> On 6/13/2010 5:34 PM, Rich Shepard wrote:
>
>> I'm upgrading PSTricks. There are 50 modules, and the relevant .tex files
>> are each in its own directory. I thought that I could cd to the parent
>> directory of these and use 'cp -R *.tex
>> /usr/share/texmf/tex/generic/pstricks' but the shell tells me it cannot find
>> a *.tex file.
>>
>> Do I need to use a for loop so the shell knows to look in each directory
>> for the .tex file to copy? Or have I not used the cp command correctly?
>>
>>
>
> Are you wanting to copy just the .tex files, and into the same directory
> structure?
>
> This should do that:
>
> |tar cf - *.tex | ( cd /target; tar xfp -)|
>
> Not tested. I've used similar for backing up to disk.
>
If that doesn't work, you could try something like this ...
Regards
Fred James
#! /bin/bash
# fooer.sh
#
------------------------------------------------------------------------------
# Fred James - fredjame at fredjame.cnc.net - 13 June 2010
# based on earlier versions by the same author, on the same
general idea
# distributed free of cost, and without remedy, entirely at the user's
# own risk
#
------------------------------------------------------------------------------
# change this line to suit
Here="/home/fredjame/toolbox/sandbox/foo"
#
------------------------------------------------------------------------------
Base=$Here
Cmd=$Base/fooer.sh
Sw=0
if test $# -eq 1
then
Here=$1
Sw=1
cd $Here
fi
if test $Sw -eq 1
then
Count=`ls -l *.tex | wc | gawk '{ print($1) }'`
if test $Count -ge 1
then
cp *.tex $Base
fi
fi
for file in `ls`
do
if test -d $file
then
echo "$file is directory"
$Cmd $Here/$file
fi
done
#
------------------------------------------------------------------------------
exit 0
#
------------------------------------------------------------------------
[EOF]
More information about the PLUG
mailing list