L=`basename $PWD` # Get name of the current directory
D=`dirname $PWD` # Get the path to the current directory, without its name.
S=`basename $D`_$L # Append the name of the current directory to the name of the directory below it.
M=`ls -d /ccshare/linux/c_files/anand/*$S | head -n 1` # A basically insane way to get the first file in that directory whose name ends with the $S name above.
if [ -z $M ] ; then
can not find module directory # Broken; presumably meant to be printed to stderr.
# (printf '%s\n' 'Cannot find module directory.' ?)
exit 1 # Signal failure to any future commands.
fi
mkdir -p modules && # Make the modules directory.
cp `find $M -type f` modules/ && # A basically insane way to copy the files in "the module directory" to the directory named "modules"
chmod -R u+rw modules/ # Set permissions recursively, even though this directory will be flat.
最好这样写:
#!/bin/bash
# Get the name of the directory below this one.
dirBelow="${PWD%/*}"
dirBelow="${dirBelow##*/}"
# Make the modules directory.
mkdir -p modules
# Copy the files in the "module directory" into the directory named "modules".
find /ccshare/linux/c_files/anand/*"$dirBelow_${PWD##*/}" -type f -exec cp {} "$PWD/modules/" +
chmod u+rw modules/*