Skip to content

Instantly share code, notes, and snippets.

@dm4
Created December 11, 2011 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dm4/1459139 to your computer and use it in GitHub Desktop.
Save dm4/1459139 to your computer and use it in GitHub Desktop.
trace.sh
#!/bin/bash
[ -z "$1" ] && echo '請輸入目錄' && exit
[ ! -d "$1" ] && echo '請輸入目錄' && exit
trace() {
if [ -d "$1" ]; then
for file in "$1/"*.txt
do
echo "$file"
name=`echo "$file" | sed 's/\.txt$/.log/'`
echo '#--Homework2--#' >> "$name"
cat "$file" >> "$name"
echo "Create $name"
done
for file in "$1/"*
do
[ -d "$file" ] && trace "$file"
done
fi
}
trace "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment