23 lines
611 B
Bash
23 lines
611 B
Bash
#!/usr/bin/env bash
|
|
# When files or symlinks may include a space in the name,
|
|
# this style of looping over them can come in handy.
|
|
#
|
|
# Save the current value of IFS, so you can restore it later. Split on newlines.
|
|
old_ifs=$IFS
|
|
IFS=$'\n'
|
|
|
|
# Find all symlinks and print each one
|
|
links=$(find ~ -type l -maxdepth 1)
|
|
|
|
for link in $links
|
|
do
|
|
echo "Found Link: $link"
|
|
done
|
|
|
|
# Restore the original IFS value
|
|
IFS=$old_ifs
|
|
|
|
# While this can be used to cover a specific edge case, if you change the IFS
|
|
# variable often, that is a sign that a programming or other scripting language
|
|
# would provide a better solution
|