Advertisement
metalx1000

BASH Loop until key press

Aug 16th, 2024
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. #!/bin/bash
  2. ######################################################################
  3. #Copyright (C) 2024 Kris Occhipinti
  4. #https://filmsbykris.com
  5.  
  6. #This program is free software: you can redistribute it and/or modify
  7. #it under the terms of the GNU General Public License as published by
  8. #the Free Software Foundation version 3 of the License.
  9.  
  10. #This program is distributed in the hope that it will be useful,
  11. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. #GNU General Public License for more details.
  14.  
  15. #You should have received a copy of the GNU General Public License
  16. #along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. ######################################################################
  18.  
  19. clear
  20. while [ 1 ]; do
  21. # \r clears to begining of line
  22. printf "\r$(date)"
  23. #wait 0.25 seconds for user input
  24. read -t 0.25 -N 1 input
  25. #if there is any input break out of loop
  26. [[ $input ]] && break
  27. done
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement