As a simple example, I want to write a CLI script which can print =
across the entire width of the terminal window.
#!/usr/bin/env php
echo str_repeat('=', ???);
or
#!/usr/bin/env python
print '=' * ???
or
#!/usr/bin/env bash
x=0
while [ $x -lt ??? ]; do echo -n '='; let x=$x+1 done; echo
Answer
tput cols
tells you the number of columns.tput lines
tells you the number of rows.
No comments:
Post a Comment