-
Notifications
You must be signed in to change notification settings - Fork 304
Expand file tree
/
Copy pathscan_link.sh
More file actions
executable file
·37 lines (28 loc) · 1014 Bytes
/
Copy pathscan_link.sh
File metadata and controls
executable file
·37 lines (28 loc) · 1014 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
set -e
set -o xtrace
TOPDIR=$(cd $(dirname "$0") && pwd)
cd $TOPDIR/../
echo "#!/bin/bash" > $TOPDIR/create_link.sh
echo "set -e" >> $TOPDIR/create_link.sh
echo "set -o xtrace" >> $TOPDIR/create_link.sh
for n in `find . -name "*"`; do
cnt=`ls -l $n | head -1 | grep "\->" | wc -l`
if [[ $cnt -eq 1 ]]; then
source_file=`ls -l $n | awk '{print $11}'`
link_file=`ls -l $n | awk '{print $9}'`
d_path=`dirname $link_file`
echo $n >> /tmp/log
echo $d_path >> /tmp/log
file=$TOPDIR/create_link.sh
echo "if [[ ! -e $link_file ]]; then" >> $file
echo " old_dir=\`pwd\`" >> $file
echo " cd $d_path" >> $file
echo " ln -s $source_file ${link_file##*/}" >> $file
echo " cd \$old_dir" >> $file
echo "fi" >> $file
echo >> $file
fi
done
echo "set +o xtrace" >> $TOPDIR/create_link.sh
set +o xtrace