Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env awk
- BEGIN {
- # helper
- if ( !ARGV[2] || ARGV[1] == "--help" )
- {
- print "\nUsage: awk -f film.awk [speed in second] [how many cycles] [cursorup] [bash clear]\n"
- print "\n[cursorup]: 0, no tput cuu1; 1, yes tput cuu1"
- print "\n[bash clear]: 0, tput clear; 1, clear; command for each cycle"
- print "\n[bash clear]: 2, tput clear; 3, clear; command for each print"
- exit 1
- }
- # parameters
- pos = 0
- sec = ARGV[1]
- how = ARGV[2]
- cup = ARGV[3]
- bas = ARGV[4]
- "tput clear" | getline Clear;
- "tput cuu1" | getline CursorUp;
- data[1] = "|"
- data[2] = "/"
- data[3] = "-"
- data[4] = "\\"
- # main
- for ( ; pos <= how; pos++ )
- {
- clearEcho( 0 )
- for ( c in data )
- {
- clearEcho( 2 )
- print data[c]
- if ( cup )
- printf CursorUp
- system( "sleep "sec )
- }
- }
- }
- # function
- function clearEcho ( ori )
- {
- if ( !ori )
- {
- ori = 0
- num = 1
- }
- else
- num = ori + 1
- if ( bas == ori )
- printf Clear;
- else
- if ( bas == num )
- system( "clear" )
- if ( bas == ori || bas == num )
- print "cycle "pos
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement