 Simple UNIX commands  I/O techniques in C++  Solutions to Lab#0 problems  Solutions to Lab#1 problems 1.

Slides:



Advertisements
Similar presentations
CS1020 Week 3: 29th January 2015.
Advertisements

UNIT 12 UNIX I/O Redirection.
Learning Unix/Linux Bioinformatics Orientation 2008 Eric Bishop.
1 Reading Assignments Linux, g++ & dropboxes Simple C/C++ Program (again) Edit, Compile, Test, Submit CSE Lecture 2 – More Preliminaries.
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
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.
Dayu Zhang 9/8/2014 Lab02. Example of Commands pwd --- show your current directory This is home of venus, not your home directory Tilde: means you are.
1 10/29/07CS150 Introduction to Computer Science 1 Reading from and Writing to Files Section 3.12 & 13.1 & 13.5.
UnixUnix Basic. Convention Italic text indicates text displayed by the computer system. For example, login: indicates a login prompt displayed by the.
CS 202 Computer Science II Lab Fall 2009 September 3.
Guide To UNIX Using Linux Third Edition
T UTORIAL OF U NIX C OMMAND & SHELL SCRIPT S 5027 Professor: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2015.
CS1020: Intro Workshop. Topics CS1020Intro Workshop Login to UNIX operating system 2. …………………………………… 3. …………………………………… 4. …………………………………… 5. ……………………………………
Lecture 02CS311 – Operating Systems 1 1 CS311 – Lecture 02 Outline UNIX/Linux features – Redirection – pipes – Terminating a command – Running program.
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.
CS 117 Section 2 + KNET Computer accounts – ed to KNET students –Change password Homework 1 Lab Tutors –In lab for next 2 weeks –Will help you with.
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction What is Unix? An operation system (OS), similar to Windows, MacOS X Why learn Unix? Greatest Software.
L INUX C OMMAND L INE I NTERFACE G UNAANBAN.G
CS 141 Labs are mandatory. Attendance will be taken in each lab. Make account on moodle. Projects will be submitted via moodle.
Using Macs and Unix Nancy Griffeth January 6, 2014 Funding for this workshop was provided by the program “Computational Modeling and Analysis of Complex.
Introduction to C++ - How C++ Evolved Most popular languages currently: COBOL, Fortran, C, C++, Java (script) C was developed in 1970s at AT&T (Richie)
1 Unix Editors (ee, ed, ex, vi, vim) and Compilers (g77, gcc) Speaker: Li-Wen Chen Date:
Help session: Unix basics Keith 9/9/2011. Login in Unix lab  User name: ug0xx Password: ece321 (initial)  The password will not be displayed on the.
Unix Primer. Unix Shell The shell is a command programming language that provides an interface to the UNIX operating system. The shell is a “regular”
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction Unix-like system is everywhere Linux Android for smartphones Google Chrome OS for Chromebook Web.
AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG.
The UNIX development environment CS 400/600 – Data Structures.
Vim Editor and Unix Command gcc compiler Computer Networks.
1 Editing a C Program 01/16/15. 2 Objective Use Linux to edit, compile and execute a C program.
Carnegie Mellon Linux Boot Camp Jenna MacCarley, Peter Pearson, Shashank Goyal 9/19/2015.
CS240 Computer Science II Introduction the Unix File System and File Related Utilities Based on “UNIX for Programmers and Users” by G.Class and K. Ables.
1 Lab 2 “Hello world” in Unix/Linux #include "std_lib_facilities_4.h" int main(){ cout
1 Operating Systems Lecture 2 UNIX and Shell Scripts.
Getting started: Basics Outline: I.Connecting to cluster: ssh II.Connecting outside UCF firewall: VPN client III.Introduction to Linux IV.Intoduction to.
Unix Environment Input Output 2  List Content (ls) ◦ ls (list current directory) ◦ ls –all (include hidden files/folders)  Make directory (mkdir) ◦
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.
Isecur1ty training center Presented by : Eng. Mohammad Khreesha.
Introduction to Programming Using C An Introduction to Operating Systems.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 2a – A Unix Command Sampler (Courtesy of David Notkin, CSE 303)
More on Using onyx 8/28/13. Program 1 Due a week from today. See website for details.
PTA Linux Series Copyright Professional Training Academy, CSIS, University of Limerick, 2006 © Workshop III - Part B Shell Commands Professional Training.
AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG.
Dayu Zhang 9/10/2014 Lab03. Outline Brief Review of the 4 Steps in Hello.cpp Example Understand endl and \n Understand Comment Programming Exercise -
Unix Fundamentals CS 127. File navigation cd - change directory cd /var/log cd /etc/apache2 cd ~/Desktop ~ is a shortcut for the home directory.
Introduction to UNIX and Linux.  Written by Dennis Ritchie and Ken Thomsom at Bell Labs in 1969  Initially written in assembly language and a high-level.
CS 120 Extra: The CS1 Server Tarik Booker CS 120.
Unix Lab Fall Shell Scripting ●Through the shell (LXTerminal) you can: ●Run programs. ●Interact with the file system. ●Change settings. ●Send/receive.
Learning Unix/Linux Based on slides from: Eric Bishop.
UNIX To do work for the class, you will be using the Unix operating system. Once connected to the system, you will be presented with a login screen. Once.
Tutorial of Unix Command & shell scriptS 5027
CS1010: Intro Workshop.
California State University Fresno
UNIX The Basics Source:
Some Linux Commands.
Useful Linux Commands.
CS1010 Programming Methodology
Shell Script Assignment 1.
Tutorial of Unix Command & shell scriptS 5027
Tutorial of Unix Command & shell scriptS 5027
Text Editors Vim (Chapter 6) Emacs (Chapter 7)
Tutorial of Unix Command & shell scriptS 5027
Run Java file with Window cmd
Linux Shell Script Programming
Command line.
Reading from and Writing to Files
Lab 2: Terminal Basics.
Reading from and Writing to Files
Presentation transcript:

 Simple UNIX commands  I/O techniques in C++  Solutions to Lab#0 problems  Solutions to Lab#1 problems 1

Unix Environment Input Output 3

 Change Directory (cd) ◦ cd [directory name] ◦ Use [Tab] button for auto-completion  List Content (ls) ◦ ls (list current directory) ◦ ls –all (include hidden files/folders)  Remove Directory Entries (rm) ◦ rm [file/folder name]  C++ Compile (g++) ◦ g++ -Wall myprogram.cpp –o myprogram ◦ -o option is used to specify the output file name. This option is optional. By default the output file name is “a.out”. -Wall is used to show all warnings. 4

 Edit File in VIM (vim) ◦ vim [file name]  Running C++ Program ◦./myprogram (or./a.out) ◦./myprogram [output file] (input/output redirection)  Checking for Difference (diff) ◦ diff [file name] [file name] ◦ Difference in a single space or an extra line will be noted  Manual (man) ◦ man [command name] ◦ When you are not sure what the command does, or what parameter it expects 5

 Command Mode: (to get into command mode, press ESC key) 1. dd or :d → Delete the current line 2. :q! → Exit without saving changes 3. :wq or ZZ → Save and Exit 4. /[pattern] → Search for the pattern ◦ n → Search next in the same direction ◦ N → Search next in the opposite direction  See “Editor” in CS1020 Online web page: ◦ 6

Unix Environment Input Output 7

 use istream cin  Types of Input: (from Lab 0 Problem 1) o Type 1: Number of Operations is specified o Type 2: Read until Terminating Special Character/String o Type 3: Read until End of File 8

int numOps; cin >> numOps; for (int i=0; i<numOps; i++) { // Read Other Inputs } 9 int numOps; cin >> numOps; while(numOps--) { // Read Other Inputs } Method 2 (shorter ): Method 1: Why the second method works?

 Steps: 1. Initialize a variable to store the input 2. Read the First Input 3. Loop until Terminating Special Character/String encountered 4. Read into tempInput again 10 string tempInput; cin >> tempInput; while (tempInput != TERMINATING_STRING) { // Read Other Input (if exist) cin >> tempInput // Step 4 }

 Steps: 1. Initialize the variable to store the input 2. Loop until End of File 11 while (cin >> tempInput) { // Read Other Input }

 Combines two or more different input types into a single program ◦ e.g.: Type 3 Input on the Outside, Type 1 Input on the Inside. 12 int numOps; while (cin >> numOps) { for (int i=0; i<numOps; i++) { // Read Other Inputs }

Unix Environment Input Output 13

 With Extra Line at the End  Without Extra Line at the End 14 cout << "Output String Here" << endl; cout << "Output String Here“; cout << "Output String Here\n";

 Matrix Type, End Space  Matrix Type, End Not Space 15 for (int i=0; i<numLine; i++) { for (int j=0; j<numOut; j++) { cout << output << " "; } cout << endl; } for (int i=0; i<numLine; i++) { cout << output; for (int j=1; j<numOut-1; j++) { cout << output << “ “; } cout << output << endl; }

END OF FILE