Cs288 Intensive Programming in Linux

Slides:



Advertisements
Similar presentations
Find Command Characteristics –Locate files descending from multiple starting points –Employs regular expressions Examples On entire system: >find / -name.
Advertisements

CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
Now, return to the Unix Unix shells: Subshells--- Variable---1. Local 2. Environmental.
More Shell Programming Learning Objectives: 1. To learn the usage of environment (shell) variables in shell programming 2. To understand the handling of.
CSE 303 Lecture 2 Introduction to bash shell
Introduction to Unix – CS 21 Lecture 13. Lecture Overview Finding files and programs which whereis find xargs Putting it all together for some complex.
CS 497C – Introduction to UNIX Lecture 4: Understanding the UNIX Command Chin-Chih Chang
Lecture 01CS311 – Operating Systems 1 1 CS311 – Lecture 01 Outline Course introduction Setting up your system Logging onto the servers at OSU with ssh.
Lecture 02CS311 – Operating Systems 1 1 CS311 – Lecture 02 Outline UNIX/Linux features – Redirection – pipes – Terminating a command – Running program.
Bash Shell Scripting 10 Second Guide Common environment variables PATH - Sets the search path for any executable command. Similar to the PATH variable.
Unix Filters Text processing utilities. Filters Filter commands – Unix commands that serve dual purposes: –standalone –used with other commands and pipes.
Shell Script Examples.
Shell Programming, or Scripting Shirley Moore CPS 5401 Fall August 29,
Introduction to Linux Workshop February Introduction Rob Lane & The HPC Support Team Research Computing Services CUIT.
1 Day 16 Sed and Awk. 2 Looking through output We already know what “grep” does. –It looks for something in a file. –Returns any line from the file that.
Sydney Opera House. Week Three Agenda Administrative Issues Link of the week Review week two lab assignment This week’s expected outcomes Next lab assignment.
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
10/1/2015Course material created by D. Woit 1 CPS 393 Introduction to Unix and C START OF WEEK 5 (UNIX) 10/1/2015Course material created by D. Woit 1.
Day 2 Review of ITSK1601 – Intro Unix.. Break up into Cousin groups Each cousin group will work as a team. Each team will need 5 blank sheets of paper.
Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.
Shell Scripting Todd Kelley CST8207 – Todd Kelley1.
Session 2 Wharton Summer Tech Camp Basic Unix. Agenda Cover basic UNIX commands and useful functions.
UNIX/LINUX Shells Shell is an UNIX/LINUX command interpreter. Shell command can be internal or external. The code to execute an internal command is part.
Introduction to Linux OS (IV) AUBG ICoSCIS Team Prof. Volin Karagiozov March, 09 – 10, 2013 SWU, Blagoevgrad.
Introduction to Bash Programming Ellen Zhang. Previous three classes What have we learnt so far ?
Linux Operations and Administration
Keyword Shell Variables The shell sets keyword shell variables. You can use (and change) them. HOME The path to your home directory PATH Directories where.
UNIX Shell Script (1) Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology
Module 6 – Redirections, Pipes and Power Tools.. STDin 0 STDout 1 STDerr 2 Redirections.
Agenda Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Review next lab assignments Break Out Problems.
Week Two Agenda Announcements Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Next lab assignments.
Introduction to Unix – CS 21 Lecture 12. Lecture Overview A few more bash programming tricks The here document Trapping signals in bash cut and tr sed.
Chapter Four I/O Redirection1 System Programming Shell Operators.
Lecture One. Objective: Provide description of the Command-Line Editor of Linux operating system. Enable students to understand the practical side of.
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands: which, passwd, date, ps / kill Working with Files: file, touch, cat, more, less, grep,
Introduction to Scripting Workshop October
Week Two Agenda Announcements Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Next lab assignments.
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
Sydney Opera House. Week Three Agenda Administrative Issues Link of the week Use of the Virtual Machine Review week two lab assignment This week’s expected.
CS 245 – Part 1 Using Operating Systems and Networks for Programmers Jiang Guo Dept. of Computer Science California State University Los Angeles.
If condition1 then statements elif condition2 more statements […] else even more statements fi.
Group, group, group One after the other: cmd1 ; cmd2 One or both: cmd1 && cmd2 Only one of them: cmd1 || cmd2 Cuddling (there):( cmd1 ; cmd2 ) Cuddling.
CS 403: Programming Languages Lecture 20 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
Comp 145 – Introduction to UNIX $200 $400 $600 $800 $1000 $200 $400 $600 $800 $1000 $200 $400 $600 $800 $1000 $200 $400 $600 $800 $1000 UNIX Processes.
Introduction to Scripting Workshop February 23, 2016.
Bash Shell Scripting 10 Second Guide.
Cs288 Intensive Programming in Linux
cs Intensive Programming in Linux spring 2017
CS306 Lab Workout 2 Fall 2017.
Chapter 11 Command-Line Master Class
Prepared by: Eng. Maryam Adel Abdel-Hady
Linux 101 Training Module Linux Basics.
Cs288 Intensive Programming in Linux
Cs288 Intensive Programming in Linux
Week Three Agenda Link of the Week Review Week Two Information
The UNIX Shell Learning Objectives:
Part 1: Basic Commands/Utilities
Sydney Opera House.
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands:
Unix Scripting Session 4 March 27, 2008.
Shell Script Assignment 1.
CSE 374 Programming Concepts & Tools
Sarah Diesburg Operating Systems CS 3430
What is Bash Shell Scripting?
UNIX Reference Sheets CSE 2031 Fall 2010.
awk- An Advanced Filter
More advanced BASH usage
Linux Shell Script Programming
CSE 303 Concepts and Tools for Software Development
Review.
Presentation transcript:

Cs288 Intensive Programming in Linux Instructor: C F Yurkoski Christopher.f.yurkoski@njit.edu Section web site: https://web.njit.edu/~yurkowsk/cs288.html 6-9-15

6-9-15

Linux access ssh to afs5.njit.edu or use putty, etc. 6-9-15

Quiz 1 results Not yet available 6-9-15

Quiz1 revu 6-9-15

Question 1 I => ID => IDD => IDDD => DDDD => 1DDD => 12DD => 123D => 1234 6-9-15

Quiz revu cont. 6-9-15

scoping 6-9-15

Quiz revu 6-9-15

PATH variable colon separated list searched in order can include relative paths like . 6-9-15

Other commands and misc & ; ! || && cut –c -f sort –n –r grep –v –I $RANDOM $$ read fc tr diff ls -l 6-9-15

Grep examples grep "^am" /etc/passwd grep "^[abc]" /etc/passwd | more grep "^[a-c]" /etc/passwd | more grep "nologin$" /etc/passwd grep "^a.*nologin$" /etc/passwd grep "^a.a.*nologin$" /etc/passwd grep -v "^a.a.*nologin$" /etc/passwd 6-9-15

Cut examples cut -c 10-20 /etc/passwd cut -c -10 /etc/passwd cut -d ":" -f 5 /etc/passwd cut -d ":" -f 2,5 /etc/passwd cut -d ":" -f 3-5 /etc/passwd 6-9-15

problem 1, due this week Write a Bash script, count.sh, which builds a table of counts for the commands under /bin which start with each letter. For example, if there are 3 commands starting with "a" (alsaumute, arch & awk) while there may be 2 commands starting with "z" (zcat & zsh). The first and last lines your script will print would be: a 3 ... z 2 Hint: use loop and array to design and implement this script. 6-9-15

Homework 1 revu ls /bin > /tmp/x letters=(a b c d e f g h i j k l m n o p q r s t u v w x y z) for i in ${letters[*]} do x=0 echo -n "$i " grep "^${i}" /tmp/x | while read file let x=x+1 echo $x > count done cat count 6-9-15

Problem 2 Write a Bash script, reverse.sh, which reverses the contents of a directory passed as a parameter. For example, assuming /my/dir contains cache cron games lib log run tmp, your program "reverse.sh /my/dir" will return "tmp run log lib games cron cache." Hint: use an array and two functions: main() and reverse(). Do not use the built-in command sort -r. 6-9-15

problem 3 Write a Bash script, filter.sh, which prints those files/directories that have the size greater than the average file size of the directory passed as its first argument . Suppose for example that the directory /my/dir has five files/directories with size in parentheses : a (100) b (10) c (100) d (100) e (20), your program "filter.sh /my/dir" will list "a c d" since the size of each of these 3 files is greater than the average file size of 66. Hint: you can use 3 functions to do this: main, average, and filter, where main calls average and filter, and average computes the average file size of a directory and filter filters out those that have less than the average. 6-9-15

problem 4 Write a Bash script, insert-sort.sh, which sorts a list of command line parameters in ascending order. For example, your command will look something like:  $ insert-sort.sh 7 2 3 9 -1 and type enter. Your program will return: -1 2 3 7 9 Use only basic commands and array. Do not use any built-in commands that sort array. 6-9-15