clear command to c command

June 30, 2005 at 15:55:19
Specs: WinXP and Linux, P4 / 256MB

In Unix, the “clear” command clears the screen, ok, how can I make a file (.bat in DOS) to execute a command like “c” (clear) to clear the screen in UNIX and not have write “clear” ?


Don´t freak out until you know the facts...Relax...!

See More: clear command to c command

Report •

June 30, 2005 at 15:57:09

You could put the following in your login profile, and the syntax might be a bit different for various shells:

alias c=clear

Report •

June 30, 2005 at 17:30:27

In DOS, it's, "cls" I believe. Is that what you were asking? Good luck!

Robert Pectol

Report •

June 30, 2005 at 18:53:03

What I want to do is this....

In DOS "cls" makes the clear screen, I agree with that, but I use UNIX too (Fedora Core).

My intention is not to write "clear" on the terminal (UNIX), I just want to type "c" and that the "c" makes de clear command.

In DOS you can make a .bat file for some command on the prompt, I want to know how can I make a command typing "c" and not the whole "clear" command (on UNIX).

Don´t freak out until you know the facts...Relax...!

Report •

Related Solutions

June 30, 2005 at 18:54:12

And how.....

Need just a little help.

In witch directory can I create the c=clear ?

Don´t freak out until you know the facts...Relax...!

Report •

July 1, 2005 at 06:37:09

It is common (but not required) to have a "login profile script" that runs automatically when you log in, for the purpose of setting up your session environment such as desired variables and aliases, checking your mail, etc.

This script will be in your home directory, and the name of the script is .profile for bourne and korn shells. Filenames that begin with a dot are called hidden files, and they are not included on a directory listing by default, but you can include them by specifying the -a option.

Do this to see all the files in your home directory, including hidden files:

ls -a
ls -la
ls -lau

The first ls command gives just the filenames. The second ls command also specifies the long option to see more info for each file, including the last modify date. The third ls command includes the u option which says to display the last access date instead of the last modify date.

If you do have a login profile script, you will see it listed, and that last ls command will show when it was last accessed, which should be when you last logged in.

Add your desired aliases to your login profile script, or create a login profile if you do not yet have one.

Then log in again so that the login profile will execute. Variables and aliases are in your "environment", and are available regardless of what directory you are in. Instead of logging in again, you could run your new profile script, but note that instead of simply running it, you would have to "source" it by putting a dot-space in front of it like:

. .profile

Without putting the dot-space in front of it, it would run as a child process without impacting the current shell environment.

Also, you can create an alias at any time. Just create the alias at the command prompt, and that declares it in your current session. It would be lost upon logout, so that's why you put them in your login profile.

Report •

July 5, 2005 at 09:28:44

Dear Jim,

Thanks a lot for your response. Please help me ot let me know, how can I change de .profile so I can use a "c" command to clear the screen.


Don´t freak out until you know the facts...Relax...!

Report •

July 5, 2005 at 12:30:01

First, you need to determine the name of your login script. It is probably .profile but different shells use different names.

To determine which shell you are using:

echo $SHELL

Also, you can list all files in your home directory (including the hidden files) by doing:

ls -a

If a login script already exists, it will be listed by the ls command above.

Since you are just learning unix, you may not know how to use the vi editor at this point. But you can add a line to the end of your login script by doing an echo command.

Let's assume that your login script has the name: .profile

The following will either add a line to the end of an existing .profile, or will create a file named .profile if it does not exist:

echo alias c=clear >> .profile

Then after your next login, you should be able to type c to clear your screen.

Report •

July 5, 2005 at 13:49:27

I got it....jejeje.
With your help, of course.

I use VI and some other applications everyday, but still new for UNIX

I finished creating some alias on .bash_profile, since Im not the root, and other things.

Jim, Thanks again, your help was very usefull.

Don´t freak out until you know the facts...Relax...!

Report •

Ask Question