LDP/LDP/guide/docbook/abs-guide/symlinks2.sh

23 lines
602 B
Bash
Raw Normal View History

2001-10-15 14:28:18 +00:00
#!/bin/bash
# symlinks.sh: Lists symbolic links in a directory.
2012-11-27 14:56:18 +00:00
OUTFILE=symlinks.list # save-file
2001-10-15 14:28:18 +00:00
2002-07-22 15:11:51 +00:00
directory=${1-`pwd`}
# Defaults to current working directory,
#+ if not otherwise specified.
2001-10-15 14:28:18 +00:00
2002-07-22 15:11:51 +00:00
echo "symbolic links in directory \"$directory\"" > "$OUTFILE"
echo "---------------------------" >> "$OUTFILE"
for file in "$( find $directory -type l )" # -type l = symbolic links
2001-10-15 14:28:18 +00:00
do
echo "$file"
2002-07-22 15:11:51 +00:00
done | sort >> "$OUTFILE" # stdout of loop
# ^^^^^^^^^^^^^ redirected to save file.
2001-10-15 14:28:18 +00:00
2012-11-27 14:56:18 +00:00
# echo "Output file = $OUTFILE"
exit $?