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.

  • ^N, Down arrow: Move down to the next event in the history list
  • ^P, Up arrow: Move up to the previous event in the history list
  • ALT <: Move to the beginning of the history event list
  • ALT N: Forward search, next matching item
  • ALT P: Backward search, previous matching item
  • ^S: Forward search history, forward incremental search

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

% date ananova ^w
% date

Referencing history

  • ! event num: Reference an event by its event number
  • !!: Reference the previous command
  • ! character: Reference an event beginning with the specified characters
  • ! event-num: Reference an event with an offset from the first event
  • ! num-num: Reference a range of events
  • fc event-reference: Edits an event with the standard editor and then executes it
    fc -1: List recent history events, same as a history command
    fc -e: editor event-reference invokes a specified editor to a specified event

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

  • ^ represents the first argument of an event
  • $ represents the last argument
  • *, ^-$ reference all the arguments

Save time and money by making the right web hosting decision the first time.

WordPress.com

Nexcess Hosting

Visit nexcess

Inmotion Hosting

Visit Inmotionhosting

Namecheap Hosting

Visit Namecheap

iThemes Hosting

Visit ithemes

Data-Driven Reviews

  • Current & accurate reviews are based on data and supported by real user experiences.
  • The goal is to deliver the most accurate information possible based on the needs of the majority of website owners and developers, and Ananova reports deliver the most reliable indicators of web host performance.

Save time and money by making the right web hosting decision the first time.

WordPress.com

Nexcess Hosting

Visit nexcess

Inmotion Hosting

Visit Inmotionhosting

Namecheap Hosting

Visit Namecheap

iThemes Hosting

Visit ithemes

Data-Driven Reviews

  • Current & accurate reviews are based on data and supported by real user experiences.
  • The goal is to deliver the most accurate information possible based on the needs of the majority of website owners and developers, and Ananova reports deliver the most reliable indicators of web host performance.
%d bloggers like this: