Saturday, 20 August 2011

clear (clear screen),less,wc (word count)


Clears the screen.

Syntax
clear

Examples
clear

Clear the screen.

Additional information
Many newer Unix systems and Unix variants will also accept the cls command or have cls as an alias for clear.


less

The command less writes the contents of a file onto the screen a page at a time. Type
% less science.txt 

Press the [space-bar] if you want to see another page, and type [q] if you want to quit reading. As you can see, less is used in preference to cat for long files.


Simple searching using less

Using less, you can search though a text file for a keyword (pattern). For example, to search through science.txt for the word 'science', type

% less science.txt
then, still in less, type a forward slash [/] followed by the word to search
/science

As you can see, less finds and highlights the keyword. Type [n] to search for the next occurrence of the word.

wc (word count)

A handy little utility is the wc command, short for word count. To do a word count on science.txt, type

% wc -w science.txt

To find out how many lines the file has, type
% wc -l science.txt




No comments:

Post a Comment