CS 307: UNIX PROGRAMMING ENVIRONMENT KATAS FOR EXAM 2

Similar documents
CS 307: UNIX PROGRAMMING ENVIRONMENT KATAS FOR EXAM 1

CS 307: UNIX PROGRAMMING ENVIRONMENT FIND COMMAND

Table of contents. Our goal. Notes. Notes. Notes. Summer June 29, Our goal is to see how we can use Unix as a tool for developing programs

The Unix Shell. Pipes and Filters

CST Algonquin College 2

Introduction: What is Unix?

The UNIX Shells. Computer Center, CS, NCTU. How shell works. Unix shells. Fetch command Analyze Execute

Introduction To. Barry Grant

Chapter 9. Shell and Kernel

UNIX Basics. UNIX Basics CIS 218 Oakton Community College

Unix as a Platform Exercises. Course Code: OS-01-UNXPLAT

Introduction to the Linux Command Line January Presentation Topics

Shell Programming Systems Skills in C and Unix

Introduction to Linux

Unix/Linux Basics. Cpt S 223, Fall 2007 Copyright: Washington State University

LOG ON TO LINUX AND LOG OFF

Part 1: Basic Commands/U3li3es

Useful Unix Commands Cheat Sheet

CS 3410 Intro to Unix, shell commands, etc... (slides from Hussam Abu-Libdeh and David Slater)

Shell. SSE2034: System Software Experiment 3, Fall 2018, Jinkyu Jeong

INd_rasN SOME SHELL SCRIPTING PROGRAMS. 1. Write a shell script to check whether the name passed as first argument is the name of a file or directory.

5/20/2007. Touring Essential Programs

Introduction to UNIX Part II

3/8/2017. Unix/Linux Introduction. In this part, we introduce. What does an OS do? Examples

When talking about how to launch commands and other things that is to be typed into the terminal, the following syntax is used:

find starting-directory -name filename -user username

sottotitolo A.A. 2016/17 Federico Reghenzani, Alessandro Barenghi

Lec 1 add-on: Linux Intro

CS 25200: Systems Programming. Lecture 11: *nix Commands and Shell Internals

5/8/2012. Exploring Utilities Chapter 5

Processes. Shell Commands. a Command Line Interface accepts typed (textual) inputs and provides textual outputs. Synonyms:

Lecture 4. Log into Linux Reminder: Homework 1 due today, 4:30pm Homework 2 out, due next Tuesday Project 1 out, due next Thursday Questions?

BGGN 213 Working with UNIX Barry Grant

Basic Linux (Bash) Commands

EECS 470 Lab 5. Linux Shell Scripting. Friday, 1 st February, 2018

Linux at the Command Line Don Johnson of BU IS&T

Introduction to UNIX Shell Exercises

CSC209H Lecture 1. Dan Zingaro. January 7, 2015

CSCI 2132 Software Development. Lecture 5: File Permissions

UNIX COMMANDS AND SHELLS. UNIX Programming 2015 Fall by Euiseong Seo

Introduction p. 1 Who Should Read This Book? p. 1 What You Need to Know Before Reading This Book p. 2 How This Book Is Organized p.

Linux Refresher (1) 310/ Fourth Workshop on Distributed Laboratory Instrumentation Systems (30 October - 24 November 2006)

Introduction to the UNIX command line

Unix as a Platform Exercises + Solutions. Course Code: OS 01 UNXPLAT

Shells. A shell is a command line interpreter that is the interface between the user and the OS. The shell:

EECS 2031E. Software Tools Prof. Mokhtar Aboelaze

UNIX. The Very 10 Short Howto for beginners. Soon-Hyung Yook. March 27, Soon-Hyung Yook UNIX March 27, / 29

Perl and R Scripting for Biologists

1. What statistic did the wc -l command show? (do man wc to get the answer) A. The number of bytes B. The number of lines C. The number of words

Week Overview. Simple filter commands: head, tail, cut, sort, tr, wc grep utility stdin, stdout, stderr Redirection and piping /dev/null file

Recap From Last Time:

Module 8 Pipes, Redirection and REGEX

Basics. I think that the later is better.

Week 2 Lecture 3. Unix

Linux & Shell Programming 2014

CS 246 Winter Tutorial 2

CSE Linux VM. For Microsoft Windows. Based on opensuse Leap 42.2

M2PGER FORTRAN programming. General introduction. Virginie DURAND and Jean VIRIEUX 10/13/2013 M2PGER - ALGORITHME SCIENTIFIQUE

Introduction to Shell Scripting

Practical 02. Bash & shell scripting

Shells and Shell Programming

Answers to AWK problems. Shell-Programming. Future: Using loops to automate tasks. Download and Install: Python (Windows only.) R

Assignment clarifications

Operating Systems. Copyleft 2005, Binnur Kurt

Linux Command Line Interface. December 27, 2017

Introduction to Unix The Windows User perspective. Wes Frisby Kyle Horne Todd Johansen

The Unix Shell & Shell Scripts

Operating Systems 3. Operating Systems. Content. What is an Operating System? What is an Operating System? Resource Abstraction and Sharing

CS 307: UNIX PROGRAMMING ENVIRONMENT REVIEW FOR EXAM 2

Basic UNIX commands. HORT Lab 2 Instructor: Kranthi Varala

Unix Handouts. Shantanu N Kulkarni

Unix Guide. Meher Krishna Patel. Created on : Octorber, 2017 Last updated : December, More documents are freely available at PythonDSP

Sub-Topic 1: Quoting. Topic 2: More Shell Skills. Sub-Topic 2: Shell Variables. Referring to Shell Variables: More

Unix basics exercise MBV-INFX410

Review of Fundamentals

Introduction in Unix. Linus Torvalds Ken Thompson & Dennis Ritchie

EECS2301. Lab 1 Winter 2016

LAB 8 (Aug 4/5) Unix Utilities

Basic Linux Command Line Interface Guide

Introduction to Unix: Fundamental Commands

D. Delete the /var/lib/slocate/slocate.db file because it buffers all search results.

Topic 2: More Shell Skills

Basic Linux Command Line Interface Guide

The input can also be taken from a file and similarly the output can be redirected to another file.

Introduction to Unix/Linux INX_S17, Day 8,

Lab 2: Linux/Unix shell

Log into Linux Reminders: Homework 1 due today; Homework 2 due on Thursday Questions?

Chapter 1 - Introduction. September 8, 2016

Introduction to Linux Workshop 1

Linux Essentials. Programming and Data Structures Lab M Tech CS First Year, First Semester

bash, part 3 Chris GauthierDickey

Advanced Linux Commands & Shell Scripting

Unix Introduction to UNIX

22-Sep CSCI 2132 Software Development Lecture 8: Shells, Processes, and Job Control. Faculty of Computer Science, Dalhousie University

Environment Variables

Shells and Shell Programming

Welcome to Linux. Lecture 1.1

d. Permissions 600 on directory dir and 300 on file dir/foo. c. Permissions 700 on directory dir and 200 on file dir/foo.

BIOINFORMATICS POST-DIPLOMA PROGRAM SUBJECT OUTLINE Subject Title: OPERATING SYSTEMS AND PROJECT MANAGEMENT Subject Code: BIF713 Subject Description:

CS395T: Introduction to Scientific and Technical Computing

Transcription:

CS 307: UNIX PROGRAMMING ENVIRONMENT KATAS FOR EXAM 2 Prof. Michael J. Reale Fall 2014

COMMAND KATA 7: VARIABLES

Command Kata 7: Preparation First, go to ~/cs307 cd ~/cs307 Make directory dkata7 and go to it mkdir dkata7; cd dkata7 Make a script called kata7 script kata7 When we re done: exit

Command Kata 7: The Way of Bourne Start a Bash shell bash Create a shell variable BESTMOVIE= Supremacy Print value of variable echo ${BESTMOVIE} Start a new bash shell bash Print value of variable echo ${BESTMOVIE} Exit shell exit Make variable an environment variable export BESTMOVIE Start a new bash shell bash Print value of variable echo ${BESTMOVIE} Exit shell exit Exit shell again exit

Command Kata 7: The Way of the C (Shell) Start tcsh tcsh Create shell variable set ocean= Atlantic Print value of variable echo ${ocean} Create environment variable setenv OCEAN Pacific Start tcsh shell tcsh Print value of shell variable echo ${ocean} Print value of environment variable echo ${OCEAN} Exit shell exit Exit shell again exit

COMMAND KATA 8: REDIRECTION

Command Kata 8: Preparation First, go to ~/cs307 cd ~/cs307 Make directory dkata8 and go to it mkdir dkata8; cd dkata8 Make a script called kata8 script kata8 When we re done: exit

Command Kata 8 Run cat cat Type some data and hit enter Press CTRL+D (EOF) Redirect cat output to myfile cat > myfile Type some multi-line data and press CTRL+D (EOF) Print contents of myfile cat < myfile Redirect myfile to STDIN and STDOUT to yourfile cat < myfile > yourfile Print contents of yourfile cat < yourfile

COMMAND KATA 9: MORNING TEE

Command Kata 9: Preparation First, go to ~/cs307 cd ~/cs307 Make directory dkata9 and go to it mkdir dkata9; cd dkata9 Make a script called kata9 script kata9 When we re done: exit

Command Kata 9 Print list of users logged in who Pipe output of who to input of sort who sort Grab list of logged-in users before sorting who tee listwho sort Grab list of sorted logged-in users who sort tee listsort Print list of logged-in users cat listwho Print sorted list of logged-in users cat listsort

COMMAND KATA 10: CROSSING THE STREAMS

Command Kata 10: Preparation First, go to ~/cs307 cd ~/cs307 Make directory dkata10 and go to it mkdir dkata10; cd dkata10 Make a script called kata10 script kata10 When we re done: exit

Command Kata 10: Bourne Start Bash bash Try to run make (should fail) make Redirect STDOUT make > outfile Redirect STDERR make 2> errfile Redirect both STDOUT and STDERR make > bothfile 2>&1 Print outfile cat outfile Print errfile cat errfile Print bothfile cat bothfile Remove files rm *file Exit Bash exit

Command Kata 10: C-Shell Start tcsh tcsh Try to run make (should fail) make Redirect both STDOUT and STDERR make >& bothfile Redirect STDOUT to outfile (subshell), then STDERR to errfile (make > outfile) >& errfile Print outfile cat outfile Print errfile cat errfile Print bothfile cat bothfile Remove files rm *file Exit tcsh exit

COMMAND KATA 11: #YESFILTER

Command Kata 11: Preparation First, go to ~/cs307 cd ~/cs307 Make directory dkata11 and go to it mkdir dkata11; cd dkata11 Make a script called kata11 script kata11 When we re done: exit

Command Kata 11: Part 1 Open vi to create the file file1 vi file1 Hit i, and enter the following: ghi abc abc def def ESC, then SHIFT+ZZ to save and exit

Command Kata 11: Part 2 Print file1 cat file1 Get first 2 lines of file1 cat file1 head n2 Get last 2 lines of file1 cat file1 tail n2 Find abc in file1 cat file1 grep abc Get first column of file1 cat file1 cut d f 1 Get number of lines in file1 cat file1 wc l Get unique values and counts cat file1 uniq c Sort file1 cat file1 sort Count how many lines have abc cat file1 grep abc wc -l

COMMAND KATA 12: Time Travelling under an Assumed Name

Command Kata 12: Preparation First, go to ~/cs307 cd ~/cs307 Make directory dkata12 and go to it mkdir dkata12; cd dkata12 Make a script called kata12 script kata12 When we re done: exit

Command Kata 12 Start a bash shell bash Create an alias to repeat the last command alias r= fc -s Create some files touch a1 a2 a3 Re-execute command, but with a replaced by b fc s a=b Re-execute command, but with b replaced by c r b=c See what files you have ls Remove all files beginning with a through c rm [a-c]* Check your history history Check your alias alias r Get rid of your alias unalias r Check it again alias r Exit bash exit

COMMAND KATA 13: Find and Execute

Command Kata 13: Preparation First, go to ~/cs307 cd ~/cs307 Make directory dkata13 and go to it mkdir dkata13; cd dkata13 Make a script called kata13 script kata13 When we re done: exit

Command Kata 13 Find all regular files in your home find ~ -type f Find all directories in your home find ~ -type d Find all files beginning with kata find ~ -type f name kata* Print out contents of all kata files find ~ -type f name kata* exec cat {} \; Do same thing with xargs find ~ -type f name kata* xargs cat List long listing for all directories find ~ -type d exec ls ld {} \; Do same thing with xargs find ~ -type d xargs ls -ld

COMMAND KATA 14: UGO; I Stay

Command Kata 14: Preparation First, go to ~/cs307 cd ~/cs307 Make directory dkata14 and go to it mkdir dkata14; cd dkata14 Make a script called kata14 script kata14 When we re done: exit

Command Kata 14 Make a file touch myfile Give ALL permissions chmod a=rwx myfile List long format ls l Remove read, write, execute from group and others chmod go-rwx myfile List long format ls l Add read and execute to group chmod g+rx myfile List long format ls l Set user permissions to equal group chmod u=g myfile List long format ls l Add write permissions to user AND add execute to others chmod u+w,o+x myfile List long format ls l

COMMAND KATA 15: Expressing Yourself Regularly

Command Kata 15: Preparation First, go to ~/cs307 cd ~/cs307 Make directory dkata15 and go to it mkdir dkata15; cd dkata15 Make a script called kata15 script kata15 When we re done: exit

Command Kata 15 Copy dictionary file cp /usr/share/dict/words words Find all lines that end in e egrep e$ words Find all lines that begin with x egrep ^x words Find all lines that begin with x or y and end with e egrep ^[xy].*e$ words Find all lines that repeat a twice egrep a{2} words Find all lines that repeat e or s three times egrep (e{3} s{3}) words Find all lines that end in thing POSSIBLY followed by s egrep things?$ words Find all lines that end in one or more z egrep z+$ words