2021年9月4日 星期六

[ Bash 範例代碼 ] Scripts with pre-defined information

 Source From Here

- goscript.sh
  1. #!/bin/bash  
  2. read -r -p "Enter name of script: " script  
  3. read -r -p "Whats your fullname: " fname  
  4. read -r -p "Whats the description of this script: " description  
  5. script_dir_path="$HOME/ps/"  
  6.   
  7. if [ ! -d $script_dir_path ]; then  
  8.   mkdir ${script_dir_path}  
  9. fi  
  10.   
  11. script_path="${script_dir_path}/${script}"  
  12. echo "Preparing ${script_path}"  
  13. echo "#!/bin/bash" > "${script_path}"  
  14. echo  
  15. echo "###########################################" >> ${script_path}  
  16. echo  
  17. echo "#Author: " $fname >> ${script_path}  
  18. echo  
  19. echo "#Date: " $(date) >> ${script_path}  
  20. echo  
  21. echo "#Description: " $description >> ${script_path}  
  22. echo  
  23. echo "#Modified: " $(date) >> ${script_path}  
  24. echo  
  25. echo "###########################################" >> ${script_path}  
  26. echo  
  27. chmod a+x ${script_path}  
  28. vim ${script_path}  
Supplement
Linuxize - Bash read Command

沒有留言:

張貼留言

[ Python 常見問題 ] When using unittest.mock.patch, why is autospec not True by default?

  Source From  Here Question When you patch a function using  mock , you have the option to specify  autospec  as True: If you set  autospec...