Skip to content

Instantly share code, notes, and snippets.

@Abreto
Created June 23, 2018 07:43
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 Abreto/a6893f9c924c213030cf320909018562 to your computer and use it in GitHub Desktop.
Save Abreto/a6893f9c924c213030cf320909018562 to your computer and use it in GitHub Desktop.
Travel a directory recursively
#!/usr/bin/env bash
outdir=$2
function travel() {
mkdir -p $outdir/$1
for f in `ls $1`
do
if [ -d $1/$f ]; then
travel $1/$f
else
echo proccessing $1/$f ...
iconv -c -f GBK -t UTF-8 $1/$f -o "$outdir/$1/$f"
fi
done
}
travel $1
#!/usr/bin/env bash
function travel() {
for f in `ls $1`
do
if [ -d $1/$f ]; then
travel $1/$f
else
echo do something on $1/$f ...
fi
done
}
travel $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment