Skip to content

Latest commit

 

History

History
76 lines (46 loc) · 2.87 KB

File metadata and controls

76 lines (46 loc) · 2.87 KB

Regular Expressions!

  • Search for particular items within a large body of text. eg. You may wish to identify all email addresses in some content using a text editor.

  • Replace particular items. eg. You may wish to clean up some poorly formatted HTML by replacing all uppercase tags with lowercase equivalents in a text editor.

  • Validate input. eg. You may want to check that a password meets certain criteria such as, a mix of uppercase and lowercase, digits and punctuation etc in a program you are writing.

  • Coordinate actions. eg. You may wish to process certain files in a directory, but only if they meet particular conditions, in work you are doing on the command line.

  • Reformat text. eg. You may export data from one program as a text file then modify its layout so you may import it into another program using a text editor.

image

So Where and How do I use Regular Expressions?

  • Regular expressions are a feature of many pieces of software and nearly all programming languages .

Learning Regular Expressions

  • Break the regular expression down into it's individual components (So for instance, in the regular expression example above it would become b and [ia]).

  • Speak out aloud the steps of the expression. So for the above expression I might say: "First it matches a b, followed by either an i or an a" (This step may sound silly but trust me it works. You use different parts of your brain when you speak as opposed to think internally.)

  • Build the regular expression incrementally, testing as you go.

Summury

Basic Navigation!

pwd

  • Print Working Directory - ie. Where are we currently. ls
  • List the contents of a directory. cd
  • Change Directories - ie. move to another directory. Relative path
  • A file or directory location relative to where we currently are in the file system. Absolute path A file or directory location in relation to the root of the file system.

image

More About Files!

Linux is an Extensionless System

The following are common extensions:

  • file.exe - an executable file, or program.
  • file.txt - a plain text file.
  • file.png, file.gif, file.jpg - an image.

Linux is Case Sensitive

This is very important and a common source of problems for people new to Linux.

Spaces in names

A space on the command line is how we seperate items.

file obtain information about what type of file a file or directory is. ls -a List the contents of a directory, including hidden files. Everything is a file under Linux Even directories. Linux is an extensionless system Files can have any extension they like or none at all. Linux is case sensitive Beware of silly typos.