Site icon Ananova Business Web Hosting

The Linux Command Line Interface (CLI) -2

<< Prev Page – The Linux Command Line Interface (CLI)

Linux History Utility

BASH history utility keeps the list of previously entered commands, which acts as a short term memory. By default, the utility remembers 500 recent commands, whose numbers start at one or beginning characters in the commands. Histsize is a special variable in which the user can change it to any value.

$ HISTSIZE = 200

HISTFILE saves the actual history of events. 

In C-shell, history is not automatically turned ON. The set command assigns the number of records.

% set history=100

$ history to display the list of recent commands executed referred to as an event, i.e., the action being taken. Meta keys like ALT or ESC perform other history operations like searching history list.

In C-shell ^w erases recently entered word of a command

% date ananova ^w
% date

Referencing history

Pattern Substitution in C-shell

% ^pattern^ new-text
% ^dt^ dat
% !num:s/pattern/new-text

gs is used to perform global substitution

Matching Multiple Characters

‘*' Match any set of characters placed before or after a pattern. If placed before, searches the filenames that end with pattern and if placed after searches filenames that begin with a pattern e.g.

List all files with extension ‘txt.'

$ ls *.txt

List all index files

$ ls index.*

Remove all files and directories that start with wp

rm -rf wp*

‘?' Match a single character, e.g. listing all files that begin with index and have any three-letter extension

$ ls index.???

‘[]' Any character placed in the bracket gets matched in the filename. Select a range by placing a dash (-) between the uppercase and lowercase bounds

‘\' Quote special character to reference the files containing expansion characters

$ ls doc\?

$ ls My\ Documents

‘{ }' to generate a list of names, based on patter placed within the braces and separated by commas e.g. create a list of directories containing three letters of month name and a year 2020.

$ mkdir {jan, feb, mar, apr, may, june, july, aug, sep, oct, nov, dec}2020

Meta characters in C-shell


Exit mobile version