Skip to content

Instantly share code, notes, and snippets.

@Kiruha01
Last active December 8, 2020 22:42
Show Gist options
  • Save Kiruha01/e6fc43719a96b22284e7e6a5f40ae495 to your computer and use it in GitHub Desktop.
Save Kiruha01/e6fc43719a96b22284e7e6a5f40ae495 to your computer and use it in GitHub Desktop.
bash for OS lecturers
#!/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
#!/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
#!/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