Last active
December 8, 2020 22:42
-
-
Save Kiruha01/e6fc43719a96b22284e7e6a5f40ae495 to your computer and use it in GitHub Desktop.
bash for OS lecturers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ ! -e $HOME/bin/ ]] | |
then | |
mkdir $HOME/bin/ | |
fi | |
cp sf $HOME/bin/ | |
echo 'export PATH=$PATH:$HOME/bin/' >> $HOME/.bashrc | |
source $HOME/.bashrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ -e execute ]] | |
then | |
mv execute/* . | |
rm -r execute/ | |
fi | |
if [[ -e other ]] | |
then | |
mv other/* . | |
rm -r other/ | |
fi | |
if [[ -e empty ]] | |
then | |
mv empty/* . | |
rm -r empty/ | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function foo { | |
files=$(pwd)/* | |
if [[ ! -e execute ]] | |
then | |
mkdir execute | |
fi | |
if [[ ! -e other ]] | |
then | |
mkdir other | |
fi | |
if [[ ! -e empty ]] | |
then | |
mkdir empty | |
fi | |
for file in $files | |
do | |
echo $file | |
if [ -f $file ] | |
then | |
if [[ -x $file ]] | |
then | |
mv $file execute/ | |
elif [[ -s $file ]] | |
then | |
mv $file other/ | |
else | |
mv $file empty/ | |
fi | |
elif [[ -d $file && ! -s $file ]] | |
then | |
cd $file | |
foo | |
fi | |
done | |
} | |
foo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment