Scripting Languages Course 2 Diana Trandab ă ț Master in Computational Linguistics - 1 st year 2014-2015.

Slides:



Advertisements
Similar presentations
CS 497C – Introduction to UNIX Lecture 22: - The Shell Chin-Chih Chang
Advertisements

CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
Shell Programming Software Tools. Slide 2 Shells l A shell can be used in one of two ways: n A command interpreter, used interactively n A programming.
1 CSE 303 Lecture 4 users/groups; permissions; intro to shell scripting read Linux Pocket Guide pp , 25-27, 61-65, , 176 slides created by.
Shell Basics CS465 - Unix. Shell Basics Shells provide: –Command interpretation –Multiple commands on a single line –Expansion of wildcard filenames –Redirection.
File Security. Viewing Permissions ls –l Permission Values.
CS 497C – Introduction to UNIX Lecture 15: - File Attributes Chin-Chih Chang
Shell Programming Learning Objectives: 1. To understand the some basic utilities of UNIX File 2. To compare UNIX shell and popular shell 3. To learn the.
Lecture 02CS311 – Operating Systems 1 1 CS311 – Lecture 02 Outline UNIX/Linux features – Redirection – pipes – Terminating a command – Running program.
Introduction to UNIX GPS Processing and Analysis with GAMIT/GLOBK/TRACK T. Herring, R. King. M. Floyd – MIT UNAVCO, Boulder - July 8-12, 2013 Directory.
Using Linux Commands Lab 4. Using the Shell in Linux Commands Syntax  Options: could be added to the commands to change their behavior (-a, -la, --help)
LIN Unix Lecture 4 Hana Filip. LIN File Management with Shell Commands The verbose listing shows the file permissions of a given file: -rwxr-xr-x.
Shell Script Examples.
Computer Programming for Biologists Class 2 Oct 31 st, 2014 Karsten Hokamp
Advanced File Processing
1 Lecture 2 Working with Files and Directories COP 3344 Introduction to UNIX.
Introduction to Shell Script Programming
Writing Shell Scripts ─ part 1 CSE 2031 Fall September 2015.
1 Operating Systems Lecture 3 Shell Scripts. 2 Brief review of unix1.txt n Glob Construct (metacharacters) and other special characters F ?, *, [] F Ex.
8 Shell Programming Mauro Jaskelioff. Introduction Environment variables –How to use and assign them –Your PATH variable Introduction to shell programming.
– Introduction to the Shell 10/1/2015 Introduction to the Shell – Session Introduction to the Shell – Session 2 · Permissions · Users.
The UNIX Shell. The Shell Program that constantly runs at terminal after a user has logged in. Prompts the user and waits for user input. Interprets command.
LIN Unix Lecture 3 Hana Filip. LIN UNIX Resources UNIX Tutorials UNIX help for.
System Administration Introduction to Unix Session 2 – Fri 02 Nov 2007 Reference:  chapter 1, The Unix Programming Environment, Kernighan & Pike, ISBN.
Additional UNIX Commands. 222 Lecture Overview  Multiple commands and job control  More useful UNIX utilities.
Advanced File Processing. 2 Objectives Use the pipe operator to redirect the output of one command to another command Use the grep command to search for.
Introduction to Bash Programming Ellen Zhang. Previous three classes What have we learnt so far ?
CMPSC 60: Week 6 Discussion Originally Created By: Jason Wither Updated and Modified By: Ryan Dixon University of California Santa Barbara.
UNIX Shell Script (1) Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology
Shell Programming Any command or a sequence of UNIX commands stored in a text file is called a shell program. It is common to call this file a command.
Chapter Five Advanced File Processing Guide To UNIX Using Linux Fourth Edition Chapter 5 Unix (34 slides)1 CTEC 110.
CS465 - UNIX The Bourne Shell.
Chapter Five Advanced File Processing. 2 Objectives Use the pipe operator to redirect the output of one command to another command Use the grep command.
Lesson 9-Setting and Using Permissions. Overview Describing file permissions. Using execute permissions with a file. Changing file permissions using mnemonics.
1 Operating Systems Lecture 2 UNIX and Shell Scripts.
Shell Programming. The UNIX Shell  The UNIX shell listens to what you type and executes commands at your request. User command: lpr file UNIX Shell UNIX.
Chapter Five Advanced File Processing. 2 Lesson A Selecting, Manipulating, and Formatting Information.
Shell Programming Learning Objectives: 1. To understand the some basic utilities of UNIX File 2. To compare UNIX shell and popular shell 3. To learn the.
LING 408/508: Programming for Linguists Lecture 17 October 28 th.
Using Linux Commands Lab 4. Using the Shell in Linux Commands Syntax  Options: could be added to the commands to change their behavior (-a, -la, --help)
Λειτουργικά Συστήματα – Lab2 Γιάννης Πετράκης. Directory Navigation and Control  The Unix file system is set up like a tree branching out from the root.
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
1 Lecture 2 Working with Files and Directories COP 3353 Introduction to UNIX.
Introduction to Unix (CA263) Command File By Tariq Ibn Aziz.
Sed. Class Issues vSphere Issues – root only until lab 3.
UNIX file systems Learning Objectives: 1. To understand the basics of file systems 2. To understand the hierarchical structure in Unix file system 3. To.
Lesson 6-Using Utilities to Accomplish Complex Tasks.
Introduction to UNIX (part 2) CSE 2031 Fall March 2016.
File Management commands cat Cat command cat cal.txt cat command displays the contents of a file here cal.txt on screen (or standard out).
Chapter 2: Exploring the UNIX File System (For Tuesday Section) File and File Systems.
Shell scripts – part 1 Cs 302. Shell scripts  What is Shell Script? “Shell Script is series of command written in plain text file. “  Why to Write Shell.
Tutorial of Unix Command & shell scriptS 5027
Writing Shell Scripts ─ part 1
Bash Introduction (adapted from chapters 1 and 2 of bash Cookbook by Albing, Vossing, & Newham) CPTE 440 John Beckett.
The UNIX Shell Learning Objectives:
INTRODUCTION TO UNIX: The Shell Command Interface
Tutorial of Unix Command & shell scriptS 5027
Basic UNIX OLC Training.
Tutorial of Unix Command & shell scriptS 5027
Using Linux Commands Lab 3.
LING 408/508: Computational Techniques for Linguists
Permission and CHMOD.
Guide To UNIX Using Linux Third Edition
LING 408/508: Computational Techniques for Linguists
Tutorial of Unix Command & shell scriptS 5027
Shell Programming.
Introduction to UNIX (part 2)
Introduction to UNIX (part 2)
Introduction to Bash Programming, part 3
Introduction to UNIX (part 2)
Presentation transcript:

Scripting Languages Course 2 Diana Trandab ă ț Master in Computational Linguistics - 1 st year

Today’s lecture Visit and follow the tutorial to learn how to obtain the frequency of each word in a text, the frequency of bigrams and trigrams.

Other useful commands Transform uppercase characters into lower case: tr ’[:upper:]’ ’[:lower:]’ < INFILE This command is not needed before sort, since sort can ignore the difference between upper and lower case characters: sort –f filename Sort with the second field as key field sort +1 –nr freq_list Working with references. Read the explanations on the egrep guide (page 29) sed -n ’s/.*(\(.*\)).*/\1/p’ sonnets.txt

4 File Management with Shell Commands Options can be combined – a verbose listing of files by last modification date: ls -lt

5 File Management with Shell Commands The verbose listing shows the file permissions of a given file: -rwxr-xr-x directories have a "d" in the first column regular files have a "-". the remaining 9 characters indicate owner, group, and world permissions of the file An "r" indicates it's readable "w" is writable, "x" is executable A dash in the column instead of a letter means that particular permission is turned off.

6 File Management with Shell Commands r readable w writable x executable - permission is turned off -rwxr-xr-x a plain file that is read-write-execute by the owner, and read- execute by group and world. drwx a directory that is read-write-execute by owner, and group and world have no permissions at all.

7 File Management with Shell Commands chmod [permissions] [file] Changes the permissions of the named file. You can use numbers: chmod 755 index.html The first number translates to permissions by the owner. The second is permissions for the group. The third is permissions for everyone. Number Perms no permissions 1 --x executable only 2 -w- writable only 3 -wx writable and executable 4 r--- readable only 5 r-x readable and executable 6 rw- readable and writable 7 rwx readable, writable, and executable

8 File Management with Shell Commands A second way of setting permissions is with letters: chmod u+rwx index.html chmod go+rx index.html u is the owner's ("user's") permissions g is the group permissions o is "other" or world permissions. The + sign turns the stated permissions on; the — sign turns them off If you want to change a file so that it's group writable, but not readable or executable, you'd do: % chmod g+w,g-rx index.html

9 Example of a simple shell script # This script displays the date, time, # username and current directory. echo "Date and time is:" date echo "Your username is: `whoami`" echo "Your current directory is:" pwd

10 Example of a simple shell script # This script displays the date, time, # username and current directory. lines beginning with a hash (#) are comments and are not interpreted by the Shell.

11 Example of a simple shell script # This script displays the date, time, # username and current directory. echo "Date and time is:" When used as a Shell command echo echo prints its argument When echo ing multiple words, they must be placed within quotes (single or double)

12 Example of a simple shell script # This script displays the date, time, # username and current directory. echo "Date and time is:" date echo "Your username is: `whoami`" The backquotes (`) around the command whoami illustrate the use of COMMAND SUBSTITUTION: To include the output from one command within the command line for another command, enclose the command whose output is to be included within `backquotes`.

13 Executing the shell script Before using a file as a shell script you must change its access permissions so that you have execute permission on the file, otherwise the error message Permission denied is displayed. To give yourself execute permission for the file containing the script use the command: chmod u+rwx display

14 Executing the shell script chmod u-x display To run the shell script, type its name at the prompt preceded by “sh” or “./”. The commands in the script will then execute one at a time as though you were typing them in at the terminal. sh display.sh./ display.sh

More examples of pipelines See the egrep guide, pages Some of them are already covered by the Unix for computational linguists guide. Create a script file for each exercise (i.e. for bigrams, trigrams etc.)

Great! See you next time!