Introduction to Unix (CA263) File Editing By Tariq Ibn Aziz.

Slides:



Advertisements
Similar presentations
In the last Session… ls -l command seven fields nine permissions of a file ls -ld file ownership file permissions (three-tiered file protection system)
Advertisements

CS 497C – Introduction to UNIX Lecture 8: The vi/vim Editor Chin-Chih Chang
A Guide to Unix Using Linux Fourth Edition
Cosc 4750 Getting Started in UNIX Don’t be afraid of the prompt, in linux it can be your best friend. In some cases, the only way to do certain things.
Program Development Tools IDE vs point tools Two tool flavors exist for developing embedded software: -IDEs: (Integrated Development Environments) i.e.,
CIS 240 Introduction to UNIX Instructor: Sue Sampson.
Vi Editor TA for ITIS3100: Xu Fei
Linux+ Guide to Linux Certification, Second Edition
Chapter 5 Editing Text Files
1 Using Editors Editors let you create and edit ASCII files UNIX normally includes two editors: vi and Emacs Vi and Emacs are screen editors: they display.
Guide To UNIX Using Linux Third Edition
Starting Vi Opening an existing file vi filename Creating a new file vi filename In your workshop directory, create a new file called mysong vi mysong.
CS465 - UNIX The vi Editor. Creating Files Most human-readable files on Unix are created with a text editor Unix has many, many different editors ed a.
CSCI 330 T HE UNIX S YSTEM Editing files. E DITOR C ONCEPTS Editing a file is to modify the content of a file Text editor: Enter and modify text in a.
Using Linux Text Editors. Use Non-Graphical Linux Text Editors Graphical Text Editor.
1 Unix Editors (ee, ed, ex, vi, vim) and Compilers (g77, gcc) Speaker: Li-Wen Chen Date:
Chapter 3 Mastering Editors
Chapter Four UNIX File Processing. 2 Lesson A Extracting Information from Files.
Guide To UNIX Using Linux Fourth Edition
A Guide to Unix Using Linux Fourth Edition
Chapter 3: The UNIX Editors ASCII and vi Editors.
Chapter Three The UNIX Editors. 2 Lesson A The vi Editor.
Agenda Using vi Editor Starting vi Session Command / Input Modes Entering Text Editing Text Saving vi Session Aborting Editing Session.
T HE VI EDITOR. vi has 2 modes: command mode (initial or "default" mode) insert mode [Esc] is used to switch to command mode. In general, vi commands:
Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 5.1 © Copyright IBM Corporation 2008 Unit 7 Editing.
Software I: Utilities and Internals Lecture 2 – The vi Text Editor * Modified from Dr. Robert Siegfried original presentation.
1 The EDIT Program The Edit program is a full screen text editor that allows you to: Create text files Create text files Edit an existing text files Edit.
Introduction to Vim Robbie CSCI2100 Data Structures Tutorial 3.
Introduction to Unix (CA263) Getting Started By Tariq Ibn Aziz.
UNIX Intro vi  vi is the standard UNIX text editor v Contents 1.Why use vi ? 2. vi Basics 3.Moving Around 4.Inserting Text.
Text editors Why should I use an editor ? It is very important to able to use at least one text mode editor a text mode editor is so useful on remote machines.
Unix Editors. u Editors in Unix come in two general flavours: –modal editors have "modes" v generally input mode and command mode –input mode allows entry.
Tony Kombol.  Why text edit?  Many programs and features require configuration ▪ Configuration is kept in files ▪ Usually in the /etc directory  Changes.
Unix Session IV.
Text Editing February 2 nd, 2004 Class Meeting 3.
1 of 47 Chapter 4: The vi Editor – First Look Copyright ©2008 by Pearson Education, Inc. Upper Saddle River, New Jersey All rights reserved.
Chapter Three Text Editing1 System Programming Text Editing.
VI EDITOR University of Mississippi. Vi Editor What is Vi ? ▫Vi is a screen based editor. ▫The screen of your terminal will act as a window into the file.
Chapter 9 Using Text Editors. vi Editor visual Editor, ASCII text editor, no formatting capabilities almost as powerful as MS Word, has 26 clipboards.
1 © 2012 John Urrutia. All rights reserved. Chapter 6 The vi Editor.
1May 16, 2005 Week 2 Lab Agenda Command Line FTP Commands Review More UNIX commands to learn File name expansion - * Introduction of vi.
Lesson 4-Mastering the Visual Editor. Overview Introducing the visual editor. Working in an existing file with vi. Understanding the visual editor. Navigating.
Chapter Three The UNIX Editors.
Linux Class #03. File Access Permissions Types of users in Linux: Local User (u) Group User (g) Other User (o) Each User can have 3 types of permissions:
Isecur1ty training center Presented by : Eng. Mohammad Khreesha.
Text editing and more basic commands CS 2204 Class meeting 3 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
Agenda Using vi Editor Starting vi Session Command / Input Modes Entering Text Editing Text Saving Edited File Aborting Editing Session.
Agenda Using vi Editor Starting vi Session Command / Input Modes
Vi editor Pronounced: `vee eye‘’. Agenda Describe the background of vi Editor Use vi editor to: create text files edit text files Our Goal is to create.
THE C PROGRAMMING ENVIRONMENT. Four parts of C environment  Main menu  Editor status line and edit window  Compiler message window  “Hot Keys” quick.
Linux+ Guide to Linux Certification, Second Edition Chapter 4 Exploring Linux Filesystems.
Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008 Chapter 6: The vi Editor – Last Look 1 of 55 Copyright ©2008 by Pearson Education, Inc. Upper Saddle.
BIF703 FTP (File Transfer Protocol) Utility vi editor Utility.
ITX2000 Remote hosts and web servers Prof. Xiaohong (Sharon) Gao Room: T125 Ext: Week 14 – UNIX vi text editor.
Basic VI Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology
CS:414 introduction to Unix and Linux
Chapter 3: Mastering Editors Chapter 3 Mastering Editors (Emacs)
1.4 Representation of data in computer systems Character.
Guide To UNIX Using Linux Third Edition
Vi Editor.
Unix Fundamentals - Part iii vi Editor
Vi Introduction Tony Kombol.
Linux 104 Training Module File Editing.
Text Editors Vim (Chapter 6) Emacs (Chapter 7)
The Linux Command Line Chapter 12
Chapter 2 Basic vi Editor.
Lab 7 Shell Script Reference:
CSCI The UNIX System Editing files
In the last class… The vi basics command, input and ex mode
The Linux Command Line Chapter 12
Presentation transcript:

Introduction to Unix (CA263) File Editing By Tariq Ibn Aziz

Objectives After reading this chapter, you should be able to: –Explain the basics of UNIX/Linux files, including ASCII, binary, and executable files –Understand the types of editors –Create and edit files using the vi editor

The Unix Language ASCII, American Standard Code for Information Interchange Originally, ASCII used only 7 bits (0 and 1) providing 128 characters Extended ASCII uses 8 bits to store 256 characters. For example English letter “H” has a decimal code 72. In term of bits, H is

ASCII Text Files Computer files containing nothing but printable characters are called text file. Files containing nonprintable characters, such as machine instructions, are called binary files. Unicode offers up to 65,536 characters. Unicode was developed because 256 character in ASCII are not enough to support some languages, such as Chinese, that need more than 256 characters.

ASCII Text File

USING THE VI EDITOR The vi editor is a modal editor. It works in three mode –Insert mode lets you enter text, is accessed by typing the letter “i” –Command mode Which is started by pressing Esc –Ex mode Employs an extended set of commands that were initially used in an early UNIX editor called ex. Press Esc and type (:) to enter extended command

USING THE VI EDITOR Start the vi editor with the –e option (vi –e filename), which places vi exclusively in ex mode. To use the vi editor, it is important to master the following tasks: ■ Creating a file ■ Inserting, editing, and deleting text ■ Searching and replacing text ■ Adding text from other files ■ Copying, cutting, and pasting text ■ Printing a file ■ Saving a file ■ Exiting a file

Creating a New File in the vi Editor 1.Enter vi plus the name of the file you want to create, such as vi data. 2.Press Esc, type :w

Creating a New File in the vi Editor Another Way to create a file 1.open the vi editor without specifying the file name with the vi command 2.You can save the file and specify a file name at any time by pressing Esc, typing :w filename

Using the vi Editor (continued) To create a new file in the vi editor, type vi and the name of the new file at the command prompt

Inserting Text Before you can insert text in your new file, you must use the i (insert) command. In insert mode, every character you type appears on the screen. You can return to command mode at any time by pressing the Esc key.

Repeating a Change When started, the vi editor is in command mode –To insert text into a file, you must switch to insert mode –You can repeat the line just entered with the repeat command (.) –Note: You must press Esc to use (.) to repeat the command

Moving the Cursor Designers of vi chose the letter keys because of their relative position on the keyboard.

Deleting Text While still in command mode: –To delete text, move to a character and then type “x” –You can undo a command (reverse its effects) by typing “u” –To search for a text pattern, type a forward slash (/), type the pattern, and press Enter

Searching and Replacing Text 1.Searching and replacing is a line- oriented command that executes independently of the cursor position 2.To find more instances, type n while you are in command mode

Save File and Exit Saving a file and exiting vi –You should always save the file before exiting vi, otherwise changes are lost –To save a file and continue working on it, type the :w (write) command –While in command mode, use the :wq (write and quit) command to save and exit iv, or the :zz command to exit after saving –You can also use :x to save and exit

Save File and Without Exiting

Information about file status If you are in an editing session and want to review information about the file status, press Ctrl+g or Ctrl+G The status line at the bottom of the screen displays information, including line- oriented commands and error messages.

Adding Text from Another File To copy the entire contents of one file into another file: –(1) use the vi editor to edit the file you want to copy into; and –(2) use the command :r filename, where filename is the name of the file that contains the information you want to copy

Leaving vi Temporarily If you want to execute other UNIX/Linux commands while you work with vi, you can launch a shell or execute other commands from within vi. –Go to command mode –Type :!cal (a colon, an exclamation point, and the command) –press Enter.

Using the vi Editor (continued) 1.Turn on line numbering when you want to work with a range of lines and refer to the line numbers to specify text 2.To turn on line numbering, use the :set number command

Copying or Cutting and Pasting You can use the yy command in vi to copy a specified number of lines To cut the lines from the file and store them on the clipboard, use the dd command.

Printing Text Files Sometimes you want to print a file before you exit the vi editor. Type !lpr and then type the name of the file you want to print. You might have two printers, lp1 and lp2.To print the file accounts to lp2, enter :!lpr -P lp2 accounts and press Enter.

Canceling an Editing Session You might have to cancel editing session. To cancel session, enter :q! and press Enter.

Getting Help in vi While you are in vi, press Esc, type :!man vi, and press Enter Type q and press Enter to go back into your editing session.

Chapter Summary Bytes are computer characters stored using numeric code (e.g., ASCII) The vi editor is a popular choice among UNIX/Linux users to edit text files