#!/bin/bash
LINECOUNT=wc -l 111.txt | cut -f8 -d' '
if [[ $LINECOUNT == 1 ]]; then rm -f 111.txt fi
如何处理多个文件?请指教。
答案 0 :(得分:2)
您需要for
循环来迭代所需的文件:
for f in *.txt; do # All file ending in '.txt' in the current directory
LINECOUNT=$( wc -l < "$f" )
if [[ $LINECOUNT == 1 ]]; then
rm "$f"
fi
done