拼命编写一个脚本来读取文件中的每一行文本
确定该行是否包含单引号,从行
中删除该引号如果超过2个没有动作
使用已编辑的行和未编辑的行创建新文件
我原本希望用我解析的方式遇到麻烦, 但我实际上遇到意外的文件错误?
有人可以指导我退出或结束阅读吗?我搜索了大量的EOF主题,但它确实没有意义。
read -p "User file: " fileName
if [ ! -e $fileName ];
then
echo ${fileName} doesn''t exist or is not a file
exit 1
fi
# Check |to see if it exists and throw and error if it doesn't
ls $fileName > /dev/null
cat $fileName
while read line
count= 'grep " | wc -m'
if [ "$count" < 2 ];
then
$line | tr -d '"'
fi
echo $filename >> newFile.csv
exit
答案 0 :(得分:1)
read -p "User file: " fileName
if [ ! -e $fileName ];
then
echo ${fileName} doesn''t exist or is not a file
exit 1
fi
# Check |to see if it exists and throw and error if it doesn't
#ls $fileName > /dev/null # No need for this, you already checked above
while read line
do
count= 'grep " | wc -m'
if [ "$count" < 2 ];then
$line | tr -d '"' >> newFile.csv #write to new file if condition meets
fi
done < ${filename} # read from file line by line
#echo $filename >> newFile.csv #This would print only the filename in the newfile.csv
exit