Skip to content

Instantly share code, notes, and snippets.

@pqviet07
Last active April 8, 2023 14:14
Show Gist options
  • Save pqviet07/98d78fab2830a289f333898a3ad503d2 to your computer and use it in GitHub Desktop.
Save pqviet07/98d78fab2830a289f333898a3ad503d2 to your computer and use it in GitHub Desktop.
Bash shell for productivity
#!/bin/bash
#author: Phung Quoc Viet
#description: read all line from filname then create directorys with format: line/no.line
filename="filename.txt"
n=1
while read line; do
# reading each line
mkdir "$n. $line"
touch "./$n. $line/$line.cpp"
echo -n "File No.$n: $line"
echo "... Created"
n=$((n + 1))
done <$filename
read -p "Press Enter to continue"
#!/bin/bash
#author: Phung Quoc Viet
#description: backup Postgres DataBase
directory=`pwd`
cd $directory
today=$(date '+%Y-%m-%d')
printf "Nhập database name: "
read db_name
printf "Nhập password: "
read -s pw
export PGPASSWORD=$pw
pg_dump -U postgres $db_name > "${today}_backup.sql"
echo "Đã backup Data"
read -p "Press any key to exit!"
printf "Ê mày muốn mở project nào?\n(1)Core (2)SA (3)template_CP (4)vnspoj: "
read option
if [ $option -eq "1" ]; then
code C:/FIN/Core
elif [ $option -eq "2" ]; then
code C:/FIN/SA-BA
elif [ $option -eq "3" ]; then
code C:/PrivateProject/DSA/code_template/code_template.code-workspace
else
code C:/PrivateProject/DSA/VN.SPOJ/VN.SPOJ.code-workspace
fi
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment