面试题答案
一键面试#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: $0 <directory_path>"
exit 1
fi
directory=$1
if [ ! -d "$directory" ]; then
echo "The specified path is not a directory."
exit 1
fi
for file in $directory/*.txt; do
if [ -f "$file" ]; then
echo "Processing file: $file"
tee ${file%.txt}.bak < $file
fi
done