Вопрос

I find myself unable to do a simple progress bar in a cshell script, without being able to output a form-feed. Is this totally unsupported by cshell? (or tcshell)?

Are there any alternatives to output a progress bar (and an ending point of progress), to run shell-commands between iterations of progress?

Could I use awk instead? Awk is pretty obscure to me.

Это было полезно?

Решение

You can use the printf command (which is not specific to csh or tcsh). To print a formfeed character (ctl-L):

printf '\xc'

To demonstrate:

% printf '\xc' | od -c
0000000  \f
0000001

But are you sure formfeed is the character you want? It typically has no effect in a VT-100 compatible terminal emulator.

You can print arbitrary control character sequences, as defined by termcap, with tcsh's built-in echotc command. man tcsh and search for echotc for details; man 5 termcap to see the 2-character codes recognized by echotc.

More portably (to shells other than csh and tcsh), the tput command, part of the ncurses package, is similar to echotc, but it uses terminfo capability names rather than termcap (though it also supports termcap if support is compiled into the package).

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top