Added 10 more gists.
This commit is contained in:
1
flatten.sh/README.md
Normal file
1
flatten.sh/README.md
Normal file
@@ -0,0 +1 @@
|
||||
A Bash script that recursively searches for files in subdirectories of PWD and moves them to PWD.
|
24
flatten.sh/flatten.sh
Normal file
24
flatten.sh/flatten.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#! /bin/bash
|
||||
|
||||
BASE_DIR=`pwd`
|
||||
|
||||
for dir in `ls -1 $BASE_DIR`
|
||||
do
|
||||
if [[ -d $dir ]]
|
||||
then
|
||||
cd $dir
|
||||
for i in `seq 1 100`
|
||||
do
|
||||
FILE=`ls -1`
|
||||
if [[ -d "$FILE" ]]
|
||||
then
|
||||
cd $FILE
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
mv "$FILE" $BASE_DIR
|
||||
cd $BASE_DIR
|
||||
rm -rf $dir
|
||||
fi
|
||||
done
|
Reference in New Issue
Block a user