gpt4 book ai didi

linux - 运行 sh 脚本时出错

转载 作者:太空宇宙 更新时间:2023-11-04 09:28:55 25 4
gpt4 key购买 nike

<分区>

我一直在运行我的脚本时遇到这些错误,我就是无法解决...

不断出现的错误是;

rm: 无法删除 ~/my-documents/article:': 是一个目录。它引用的目录是 $2...这是我的脚本。

#! /bin/sh

SRC=$1
DES=$2

if [ $# -ne 2 ]; then
echo "1. Please enter the source directory"
echo "2. Please enter the destination directory"
echo "thankyou"
exit
fi


if [ ! -d $1 ]; then
echo "$1 is not a directory please enter a valid directory"
echo "thankyou"
exit
fi
#gives the user a error warning the source directory is invalid


if [ -d $2 ]; then
echo "output directory exists"
else
echo "Output directory does not exist, creating directory"
mkdir $2
fi
#creates the destination directory if one doesn't exist


IFILE=$GETFILES;
FINDFILE=$FINDFILE;


find $1 -name "*.doc" > FINDFILE
find $1 -name "*.pdf" > FINDFILE
find $1 -name "*.PDF" > FINDFILE
#finds doc, pdf & PDF files and sends data to findfile.

while read -r line;
do
cp $line $2
done < FINDFILE
#files read and copied to destination directory

IFILE=$2/$GETFILES;
ls -R $1 | egrep -i ".doc | .pdf" > IFILE;

LCOUNT=0
DIFFCOUNT=0
FOUND=0
ARCHIVE=1
BASE="${line%.*}"
EXTENSION="${line##*.}"

COUNT=$COUNT;

ls $2 | grep ${line%%.*} \; | wc -l

if [[ $COUNT -eq 0 ]];
then
cp $1/$line $2;
else
echo "there is already a file in the output so need to compare"
COMP=$2/$line
fi

while [[ $FOUND -eq 0 ]] && [[ $LCOUNT -lt $COUNT ]];
do
echo "diffcount is $DIFFCOUNT"

###compares the file from the input directory to the file in
###the output directory

if [ $DIFFCOUNT -eq 0 ];
then
echo "file has already been archived no action required"
FOUND=$FOUND [ $FOUND+1 ]
else
LCOUNT=$LCOUNT [ $LCOUNT+1 ]
COMP="OUT"/"$BASE"_"$LCOUNT"."$EXTENSION"
echo "line count for next compare is $LCOUNT"
echo "get the next file to compare"
echo "the comparison file is now $COMP"
fi
if [ $LCOUNT -ne $COUNT ]; then
ARCHIVE=$ [ $ARCHIVE+1 ]
else
ARCHIVE=0
fi

if [ $ARCHIVE -eq 0 ];
then
NEWOUT="OUT"/"$BASE"_"$LCOUNT"."$EXTENSION";
echo "newfile name is $NEWOUT"
cp $1/$LINE $NEWOUT
fi

done < $IFILE
rm $IFILE

OFILE=$2/DOCFILES;
ls $2 | grep ".doc" > $OFILE;

while read -r line;
do

BASE=${line%.*}
EXTENSION=${line##*.}
NEWEXTENSION=".pdf"
SEARCHFILE=$BASE$NEWEXTENSION

find $2 -name "$SEARCHFILE" -exec {} \;
done < $OFILE
rm $OFILE

### this will then remove any duplicate files so only
### individual .doc .pdf files will exist

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com