Command line: clear alternative

Ahoy Sailors,

I used a shell script which I wanted to clear the terminal and print network speed every second. I realised that the commands “clear” and “reset” do not exist in x64 !

What I did was to create a file /usr/bin/clear (don’t forget to chmod it 755) and write in it:

printf "\033c"

and it works!

cheers

4 Likes

what are you using that’s x64?

1 Like

Works well, thanks!

You can also add /etc/profile.d/clear.sh with the following contents:

alias clear='printf "\033c"'

Same thing, really, just another option!

1 Like

my bad: aarch64 ! xperia 10 ii

Thank you for the idea deprecated! I also tried to make .bash .bashrc files and add the alias, it didn’t work.

1 Like

I have reset on my XZ2c, (symlink to tset), and clear, aarch64…

On my (arm32) system, /usr/bin/clear is owned by the ncurses package. perhaps you don’t have that installed?

1 Like

oh yes - I see that both tset and clear were modified a.few months ago… I probably installed them when building some package on the phone.

you are right, it wasn’t installed by default, I installed it, thank you!

Works, but needs root to do and is system-wide. Also, aliases don’t get evaluated when scripting.

IMO, such aliases should go in ~/.profile or ~/.bash_profile, and scripts like clear.sh into something like ~/.local/bin which is added to the PATH variable.