Skip to content

Instantly share code, notes, and snippets.

find '/pillar/Lab/' -mindepth 1 -maxdepth 1 -type d |
while read file
do
eval "alias ${file##*/}='cd $file'"
done
if there is a directory named /pillar/Lab/hi
I want this script exec alias hi='cd /pillar/Lab/hi'
find '/pillar/Lab/' -mindepth 1 -maxdepth 1 -type d |
while read file
do
alias ${file##*/}="'cd $file'"
done
目的:
如果存在 /pillar/Lab/hi 目录,则
alias hi='cd /pillar/Lab/hi'