$ true && echo "Yes." Yes. $ false echo "Yes." Yes.
|
|
- Mitchell Richards
- 5 years ago
- Views:
Transcription
1 SHELL programming
2 Shell 리스트 단순 list 구문 1 ; 구문 2 ; 구문 3 ;... AND list 구문 1 && 구문 2 && 구문 3 &&... OR list 구문 1 구문 2 구문 3... $ true && echo "Yes." Yes. $ false echo "Yes." Yes. Page 2
3 Shell 함수 함수 function_name () { } Page 3 statements [ue20@zeus ch2]$ vim function.sh #!/bin/sh yes_or_no(){ echo Is Your Name $1? while true do echo n Enter yes or no: read X case $X in y Y yes Yes YES) return 0;; n N no No NO) return 1;; *) echo Answer yes or no esac done } echo Original parameters are $* if yes_or_no $1 then echo Hi $1 else echo Oh! Sorry fi exit 0
4 Shell 에내장된명령 Shell script 내의 2 가지명령형태 명령프롬프트로부터실행가능한명령 Shell script 내에정의된내장명령 Page 4
5 Shell 에내장된명령 Break 반복문을빠져나올수있다. ch2]$ vim break.sh #!/bin/sh for var in do echo var is $var. if [ $var = 5 ] then break; fi done echo Break! exit 0 ~ [ue20@zeus ch2]$ Page 5
6 Shell 에내장된명령 : ( 콜론명령 ) 널명령, true 에대한별칭으로조건에대한논리지정 continue 반복문에서다음반복에서부터실행을계속한다. echo 문자열과줄바꿈문자를출력 eval 인자를실행 Page 6
7 Shell 에내장된명령 Exit n n 값의의미 exit 0 : 성공 exit 1 ~ 125 : 스크립트에서사용가능한에러코드. exit etc : 예약된코드. <ex> 126 : 파일이실행가능하지않았다. 127 : 명령이발견되지않았다. 128 이상 : Signal 발생 Page 7
8 Shell 에내장된명령 printf printf 형식문자열 매개변수 1 매개변수 2 printf 에서의 escape 문자. Escape Sequence \\ \a 경고 ( \b \f \n \r \t \v 설명역슬래시문자벨이나경고음을울린다 ) 백스페이스문자폼피드문자새줄문자개행문자탭문자수직탭문자 \ooo 8 진수값값 ooo 를값지는한문자 Page 8
9 Shell 에내장된명령 printf 의중요한변환지정자변환지정자설명 d 10 진수를출력한다. c 문자를출력한다. s 문자열 (string) 을출력한다. % % 문자를출력한다. Page 9
10 #/bin/bash y=1 while [ $y -le 12 ]; do x=1 while [ $x -le 12 ]; do printf "% 4d" $(( $x * $y )) let x++ done echo "" let y++ done Page 10
11 Shell 에내장된명령 return 함수반환 하나의숫자매개변수를가진다. set set 명령은쉘을위한파라미터변수를설정 Page 11
12 Shell 에내장된명령 Shift Shift 명령은모든파라미터변수를한단계아래로이동 ch2]$ vim shift.sh #!/bin/sh while [ $1!= ] do echo $1 shift done exit 0 Page 12
13 project (test_proj) cmake_minimum_required(version 2.6) set(src "main.c" "io.h" "read.c" "write.c" ) if(unix) add_custom_command( OUTPUT "${CMAKE_SOURCE_DIR}/TAGS" DEPENDS ${src} PRE_BUILD WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND etags ${src} ) endif() CMakeLists.txt 고급기술 : tag 자동생성 add_executable("test" ${src} "${CMAKE_SOURCE_DIR}/TAGS")
14 Makefile ( 내부적으로 cmake 이용 ) all: init_finished.txt if! test d../build_release ; then rm init_finished.txt; exit 1; fi cd../build_release;make no print directory debug: init_finished.txt if! test d../build_debug ; then rm init_finished.txt; exit 1; fi cd../build_debug;make no print directory VERBOSE=1 init_finished.txt:../src/cmakelists.txt mkdir p../build_release;cd../build_release;cmake G "Eclipse CDT4 Unix Makefiles"../src mkdir p../build_debug;cd../build_debug;cmake G "Eclipse CDT4 Unix Makefiles" D CMAKE_BUILD_TYPE=Debug../src touch init_finished.txt clean: rm rf../build_release rm rf../build_debug install_dependencies: sudo apt get install cmake exuberant ctags run_cgdb: make debug cgdb../build_debug/test
15 Bash version 3 Regular expressions
16 Regular Expressions grep and egrep
17 Previously Basic UNIX Commands Files: rm, cp, mv, ls, ln Processes: ps, kill Unix Filters cat, head, tail, tee, wc cut, paste find sort, uniq tr
18 Subtleties of commands Executing commands with find Specification of columns in cut Specification of columns in sort Methods of input Standard in File name arguments Special "-" filename Options for uniq
19 Today Regular Expressions Allow you to search for text in files grep command Stream manipulation: sed
20 Regular Expressions
21 What Is a Regular Expression? A regular expression (regex) describes a set of possible input strings. Regular expressions descend from a fundamental concept in Computer Science called finite automata theory Regular expressions are endemic to Unix vi, ed, sed, and emacs awk, tcl, perl and Python grep, egrep, fgrep compilers
22 Regular Expressions The simplest regular expressions are a string of literal characters to match. The string matches the regular expression if it contains the substring.
23 regular expression c k s UNIX Tools rocks. ma tch UNIX Tools sucks. ma tch UNIX Tools is okay. no match
24 Regular Expressions A regular expression can match a string in more than one place. regular expression a p p l e Scrapple from the apple. match 1 match 2
25 Regular Expressions The. regular expression can be used to match any character. regular expression o. For me to poop on. match 1 match 2
26 Character Classes Character classes [] can be used to match any specific set of characters. regular expression b [eor] a t beat a brat on a boat match 1 match 2 match 3
27 Negated Character Classes Character classes can be negated with the [^] syntax. regular expression b [^eo] a t beat a brat on a boat match
28 More About Character Classes [aeiou] will match any of the characters a, e, i, o, or u [kk]orn will match korn or Korn Ranges can also be specified in character classes [1-9] is the same as [ ] [abcde] is equivalent to [a-e] You can also combine multiple ranges [abcde ] is equivalent to [a-e1-9] Note that the - character has a special meaning in a character class but only if it is used within a range, [-123] would match the characters -, 1, 2, or 3
29 Named Character Classes Commonly used character classes can be referred to by name (alpha, lower, upper, alnum, digit, punct, cntrl) Syntax [:name:] [a-za-z] [[:alpha:]] [a-za-z0-9] [[:alnum:]] [45a-z] [45[:lower:]] Important for portability across languages
30 Anchors Anchors are used to match at the beginning or end of a line (or both). ^ means beginning of the line $ means end of the line
31 regular expression ^ b [eor] a t beat a brat on a boat ma tch regular expression b [eor] a t $ beat a brat on a boat ma tch ^word$ ^$
32 Repetition The * is used to define zero or more occurrences of the single regular expression preceding it.
33 regular expression y a * y I got mail, yaaaaaaaaaay! ma tch regular expression o a * o For me to poop on. ma tch.*
34 Match length A match will be the longest string that satisfies the regular expression. regular expression a. * e Scrapple from the apple. n o n o y e s
35 Repetition Ranges Ranges can also be specified { } notation can specify a range of repetitions for the immediately preceding regex {n} means exactly n occurrences {n,} means at least n occurrences {n,m} means at least n occurrences but no more than m occurrences Example:.{0,} same as.* a{2,} same as aaa*
36 Subexpressions If you want to group part of an expression so that * or { } applies to more than just the previous character, use ( ) notation Subexpresssions are treated like a single character a* matches 0 or more occurrences of a abc* matches ab, abc, abcc, abccc, (abc)* matches abc, abcabc, abcabcabc, (abc){2,3} matches abcabc or abcabcabc
37 grep grep comes from the ed (Unix text editor) search command global regular expression print or g/re/p This was such a useful command that it was written as a standalone utility There are two other variants, egrep and fgrep that comprise the grep family grep is the answer to the moments where you know you want the file that contains a specific phrase but you can t remember its name
38 Family Differences grep - uses regular expressions for pattern matching fgrep - file grep, does not use regular expressions, only matches fixed strings but can get search strings from a file egrep - extended grep, uses a more powerful set of regular expressions but does not support backreferencing, generally the fastest member of the grep family agrep approximate grep; not standard
39 Syntax Regular expression concepts we have seen so far are common to grep and egrep. grep and egrep have slightly different syntax grep: BREs egrep: EREs (enhanced features we will discuss) Major syntax differences: grep: \( and \), \{ and \} egrep: ( and ), { and }
40 Protecting Regex Metacharacters Since many of the special characters used in regexs also have special meaning to the shell, it s a good idea to get in the habit of single quoting your regexs This will protect any special characters from being operated on by the shell If you habitually do it, you won t have to worry about when it is necessary
41 Escaping Special Characters Even though we are single quoting our regexs so the shell won t interpret the special characters, some characters are special to grep (eg * and.) To get literal characters, we escape the character with a \ (backslash) Suppose we want to search for the character sequence a*b* Unless we do something special, this will match zero or more a s followed by zero or more b s, not what we want a\*b\* will fix this - now the asterisks are treated as regular characters
42 Egrep: Alternation Regex also provides an alternation character for matching one or another subexpression (T Fl)an will match Tan or Flan ^(From Subject): will match the From and Subject lines of a typical message It matches a beginning of line followed by either the characters From or Subject followed by a : Subexpressions are used to limit the scope of the alternation At(ten nine)tion then matches Attention or Atninetion, not Atten or ninetion as would happen without the parenthesis - Atten ninetion
43 Egrep: Repetition Shorthands The * (star) has already been seen to specify zero or more occurrences of the immediately preceding character + (plus) means one or more abc+d will match abcd, abccd, or abccccccd but will not match abd Equivalent to {1,}
44 Egrep: Repetition Shorthands cont The? (question mark) specifies an optional character, the single character that immediately precedes it July? will match Jul or July Equivalent to {0,1} Also equivalent to (Jul July) The *,?, and + are known as quantifiers because they specify the quantity of a match Quantifiers can also be used with subexpressions (a*c)+ will match c, ac, aac or aacaacac but will not match a or a blank line
45 Grep: Backreferences Sometimes it is handy to be able to refer to a match that was made earlier in a regex This is done using backreferences \n is the backreference specifier, where n is a number Looks for nth subexpression For example, to find if the first word of a line is the same as the last: ^\([[:alpha:]]\{1,\}\).* \1$ The \([[:alpha:]]\{1,\}\) matches 1 or more letters
46 Practical Regex Examples Variable names in C [a-za-z_][a-za-z_0-9]* Dollar amount with optional cents \$[0-9]+(\.[0-9][0-9])? Time of day (1[012] [1-9]):[0-5][0-9] (am pm) HTML headers <h1> <H1> <h2> <[hh][1-4]>
47 grep Family Syntax grep [-hilnv] [-e expression] [filename] egrep [-hilnv] [-e expression] [-f filename] [expression] [filename] fgrep [-hilnxv] [-e string] [-f filename] [string] [filename] -h Do not display filenames -i Ignore case -l List only filenames containing matching lines -n Precede each matching line with its line number -v Negate matches -x Match whole line only (fgrep only) -e expression Specify expression as option -f filename Take the regular expression (egrep) or a list of strings (fgrep) from filename
48 grep Examples grep 'men' GrepMe grep 'fo*' GrepMe egrep 'fo+' GrepMe egrep -n '[Tt]he' GrepMe fgrep 'The' GrepMe egrep 'NC+[0-9]*A?' GrepMe fgrep -f expfile GrepMe Find all lines with signed numbers $ egrep [-+][0-9]+\.?[0-9]* *.c bsearch. c: return -1; compile. c: strchr("+1-2*3", t-> op)[1] - 0, dst, convert. c: Print integers in a given base 2-16 (default 10) convert. c: sscanf( argv[ i+1], "% d", &base); strcmp. c: return -1; strcmp. c: return +1; egrep has its limits: For example, it cannot match all lines that contain a number divisible by 7.
49 Fun with the Dictionary /usr/dict/words contains about 25,000 words egrep hh /usr/dict/words beachhead highhanded withheld withhold egrep as a simple spelling checker: Specify plausible alternatives you know egrep "n(ie ei)ther" /usr/dict/words neither How many words have 3 a s one letter apart? egrep a.a.a /usr/dict/words wc l 54 egrep u.u.u /usr/dict/words cumulus
50 Other Notes Use /dev/null as an extra file name Will print the name of the file that matched grep test bigfile This is a test. grep test /dev/null bigfile bigfile:this is a test. Return code of grep is useful grep fred filename > /dev/null && rm filename
51 This is one line of text x xyz \m ^ $. [xy^$x] [^xy^$z] [a-z] r* r1r2 \(r\) \n \{n,m\} r+ r? r1 r2 (r1 r2)r3 (r1 r2)* {n,m} o.*o Ordinary characters match themselves (NEWLINES and metacharacters excluded) Ordinary strings match themselves Matches literal character m Start of line End of line Any single character Any of x, y, ^, $, or z Any one character other than x, y, ^, $, or z Any single character in given range zero or more occurrences of regex r Matches r1 followed by r2 Tagged regular expression, matches r Set to what matched the nth tagged expression (n = 1-9) Repetition One or more occurrences of r Zero or one occurrences of r Either r1 or r2 Either r1r3 or r2r3 Zero or more occurrences of r1 r2, e.g., r1, r1r1, r2r1, r1r1r2r1, ) Repetition input line regular expression fgrep, grep, egrep grep, egrep grep egrep Quick Reference
52 실습 다음작업을하는 shell program 을작성한다. 1. 파일내용채우기 1000.txt 파일에 a 를 1000 번씀. Page 52
53 Reference KLDP Shell Programming 의기본 초보자용 Shell Programming Page 53
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
Summer 2010 Department of Computer Science and Engineering York University Toronto June 29, 2010 1 / 36 Table of contents 1 2 3 4 2 / 36 Our goal Our goal is to see how we can use Unix as a tool for developing
More informationLecture 18 Regular Expressions
Lecture 18 Regular Expressions In this lecture Background Text processing languages Pattern searches with grep Formal Languages and regular expressions Finite State Machines Regular Expression Grammer
More informationMore Scripting and Regular Expressions. Todd Kelley CST8207 Todd Kelley 1
More Scripting and Regular Expressions Todd Kelley kelleyt@algonquincollege.com CST8207 Todd Kelley 1 Regular Expression Summary Regular Expression Examples Shell Scripting 2 Do not confuse filename globbing
More informationLecture 3 Tonight we dine in shell. Hands-On Unix System Administration DeCal
Lecture 3 Tonight we dine in shell Hands-On Unix System Administration DeCal 2012-09-17 Review $1, $2,...; $@, $*, $#, $0, $? environment variables env, export $HOME, $PATH $PS1=n\[\e[0;31m\]\u\[\e[m\]@\[\e[1;34m\]\w
More informationCommon File System Commands
Common File System Commands ls! List names of all files in current directory ls filenames! List only the named files ls -t! List in time order, most recent first ls -l! Long listing, more information.
More informationBasic Linux (Bash) Commands
Basic Linux (Bash) Commands Hint: Run commands in the emacs shell (emacs -nw, then M-x shell) instead of the terminal. It eases searching for and revising commands and navigating and copying-and-pasting
More informationPattern Matching. An Introduction to File Globs and Regular Expressions
Pattern Matching An Introduction to File Globs and Regular Expressions Copyright 2006 2009 Stewart Weiss The danger that lies ahead Much to your disadvantage, there are two different forms of patterns
More informationPattern Matching. An Introduction to File Globs and Regular Expressions. Adapted from Practical Unix and Programming Hunter College
Pattern Matching An Introduction to File Globs and Regular Expressions Adapted from Practical Unix and Programming Hunter College Copyright 2006 2009 Stewart Weiss The danger that lies ahead Much to your
More informationITST Searching, Extracting & Archiving Data
ITST 1136 - Searching, Extracting & Archiving Data Name: Step 1 Sign into a Pi UN = pi PW = raspberry Step 2 - Grep - One of the most useful and versatile commands in a Linux terminal environment is the
More informationRegular Expressions. Todd Kelley CST8207 Todd Kelley 1
Regular Expressions Todd Kelley kelleyt@algonquincollege.com CST8207 Todd Kelley 1 POSIX character classes Some Regular Expression gotchas Regular Expression Resources Assignment 3 on Regular Expressions
More informationShells & Shell Programming (Part B)
Shells & Shell Programming (Part B) Software Tools EECS2031 Winter 2018 Manos Papagelis Thanks to Karen Reid and Alan J Rosenthal for material in these slides CONTROL STATEMENTS 2 Control Statements Conditional
More informationCS 25200: Systems Programming. Lecture 10: Shell Scripting in Bash
CS 25200: Systems Programming Lecture 10: Shell Scripting in Bash Dr. Jef Turkstra 2018 Dr. Jeffrey A. Turkstra 1 Lecture 10 Getting started with Bash Data types Reading and writing Control loops Decision
More information22-Sep CSCI 2132 Software Development Lecture 8: Shells, Processes, and Job Control. Faculty of Computer Science, Dalhousie University
Lecture 8 p.1 Faculty of Computer Science, Dalhousie University CSCI 2132 Software Development Lecture 8: Shells, Processes, and Job Control 22-Sep-2017 Location: Goldberg CS 127 Time: 14:35 15:25 Instructor:
More informationsottotitolo A.A. 2016/17 Federico Reghenzani, Alessandro Barenghi
Titolo presentazione Piattaforme Software per la Rete sottotitolo BASH Scripting Milano, XX mese 20XX A.A. 2016/17, Alessandro Barenghi Outline 1) Introduction to BASH 2) Helper commands 3) Control Flow
More informationEssentials for Scientific Computing: Stream editing with sed and awk
Essentials for Scientific Computing: Stream editing with sed and awk Ershaad Ahamed TUE-CMS, JNCASR May 2012 1 Stream Editing sed and awk are stream processing commands. What this means is that they are
More informationRegular Expressions. Michael Wrzaczek Dept of Biosciences, Plant Biology Viikki Plant Science Centre (ViPS) University of Helsinki, Finland
Regular Expressions Michael Wrzaczek Dept of Biosciences, Plant Biology Viikki Plant Science Centre (ViPS) University of Helsinki, Finland November 11 th, 2015 Regular expressions provide a flexible way
More informationLecture 5. Essential skills for bioinformatics: Unix/Linux
Lecture 5 Essential skills for bioinformatics: Unix/Linux UNIX DATA TOOLS Text processing with awk We have illustrated two ways awk can come in handy: Filtering data using rules that can combine regular
More informationRegex, Sed, Awk. Arindam Fadikar. December 12, 2017
Regex, Sed, Awk Arindam Fadikar December 12, 2017 Why Regex Lots of text data. twitter data (social network data) government records web scrapping many more... Regex Regular Expressions or regex or regexp
More informationIntroduction 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.
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. 2 Conventions Used in This Book p. 2 Introduction to UNIX p. 5 An Overview
More informationQUESTION BANK ON UNIX & SHELL PROGRAMMING-502 (CORE PAPER-2)
BANK ON & SHELL PROGRAMMING-502 (CORE PAPER-2) TOPIC 1: VI-EDITOR MARKS YEAR 1. Explain set command of vi editor 2 2011oct 2. Explain the modes of vi editor. 7 2013mar/ 2013 oct 3. Explain vi editor 5
More informationGrep and Shell Programming
Grep and Shell Programming Comp-206 : Introduction to Software Systems Lecture 7 Alexandre Denault Computer Science McGill University Fall 2006 Teacher's Assistants Michael Hawker Monday, 14h30 to 16h30
More informationVi & Shell Scripting
Vi & Shell Scripting Comp-206 : Introduction to Week 3 Joseph Vybihal Computer Science McGill University Announcements Sina Meraji's office hours Trottier 3rd floor open area Tuesday 1:30 2:30 PM Thursday
More informationUnix as a Platform Exercises + Solutions. Course Code: OS 01 UNXPLAT
Unix as a Platform Exercises + Solutions Course Code: OS 01 UNXPLAT Working with Unix Most if not all of these will require some investigation in the man pages. That's the idea, to get them used to looking
More informationCS 301. Lecture 05 Applications of Regular Languages. Stephen Checkoway. January 31, 2018
CS 301 Lecture 05 Applications of Regular Languages Stephen Checkoway January 31, 2018 1 / 17 Characterizing regular languages The following four statements about the language A are equivalent The language
More informationLinux Shell Scripting. Linux System Administration COMP2018 Summer 2017
Linux Shell Scripting Linux System Administration COMP2018 Summer 2017 What is Scripting? Commands can be given to a computer by entering them into a command interpreter program, commonly called a shell
More informationUnix as a Platform Exercises. Course Code: OS-01-UNXPLAT
Unix as a Platform Exercises Course Code: OS-01-UNXPLAT Working with Unix 1. Use the on-line manual page to determine the option for cat, which causes nonprintable characters to be displayed. Run the command
More informationLOG ON TO LINUX AND LOG OFF
EXPNO:1A LOG ON TO LINUX AND LOG OFF AIM: To know how to logon to Linux and logoff. PROCEDURE: Logon: To logon to the Linux system, we have to enter the correct username and password details, when asked,
More informationPaolo Santinelli Sistemi e Reti. Regular expressions. Regular expressions aim to facilitate the solution of text manipulation problems
aim to facilitate the solution of text manipulation problems are symbolic notations used to identify patterns in text; are supported by many command line tools; are supported by most programming languages;
More informationModule 8 Pipes, Redirection and REGEX
Module 8 Pipes, Redirection and REGEX Exam Objective 3.2 Searching and Extracting Data from Files Objective Summary Piping and redirection Partial POSIX Command Line and Redirection Command Line Pipes
More informationShell. SSE2034: System Software Experiment 3, Fall 2018, Jinkyu Jeong
Shell Prof. Jinkyu Jeong (Jinkyu@skku.edu) TA -- Minwoo Ahn (minwoo.ahn@csl.skku.edu) TA -- Donghyun Kim (donghyun.kim@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu
More informationShell scripting and system variables. HORT Lecture 5 Instructor: Kranthi Varala
Shell scripting and system variables HORT 59000 Lecture 5 Instructor: Kranthi Varala Text editors Programs built to assist creation and manipulation of text files, typically scripts. nano : easy-to-learn,
More informationUNIX files searching, and other interrogation techniques
UNIX files searching, and other interrogation techniques Ways to examine the contents of files. How to find files when you don't know how their exact location. Ways of searching files for text patterns.
More informationWhile Statement Examples. While Statement (35.15) Until Statement (35.15) Until Statement Example
While Statement (35.15) General form. The commands in the loop are performed while the condition is true. while condition one-or-more-commands While Statement Examples # process commands until a stop is
More informationUnleashing the Shell Hands-On UNIX System Administration DeCal Week 6 28 February 2011
Unleashing the Shell Hands-On UNIX System Administration DeCal Week 6 28 February 2011 Last time Compiling software and the three-step procedure (./configure && make && make install). Dependency hell and
More informationPerl Regular Expressions. Perl Patterns. Character Class Shortcuts. Examples of Perl Patterns
Perl Regular Expressions Unlike most programming languages, Perl has builtin support for matching strings using regular expressions called patterns, which are similar to the regular expressions used in
More informationAdvanced training. Linux components Command shell. LiLux a.s.b.l.
Advanced training Linux components Command shell LiLux a.s.b.l. alexw@linux.lu Kernel Interface between devices and hardware Monolithic kernel Micro kernel Supports dynamics loading of modules Support
More informationCST Lab #5. Student Name: Student Number: Lab section:
CST8177 - Lab #5 Student Name: Student Number: Lab section: Working with Regular Expressions (aka regex or RE) In-Lab Demo - List all the non-user accounts in /etc/passwd that use /sbin as their home directory.
More informationShells and Shell Programming
Shells and Shell Programming 1 Shells A shell is a command line interpreter that is the interface between the user and the OS. The shell: analyzes each command determines what actions are to be performed
More informationCS Advanced Unix Tools & Scripting
& Scripting Spring 2011 Hussam Abu-Libdeh Today s slides are from David Slater February 25, 2011 Hussam Abu-Libdeh Today s slides are from David Slater & Scripting Random Bash Tip of the Day The more you
More informationBashed One Too Many Times. Features of the Bash Shell St. Louis Unix Users Group Jeff Muse, Jan 14, 2009
Bashed One Too Many Times Features of the Bash Shell St. Louis Unix Users Group Jeff Muse, Jan 14, 2009 What is a Shell? The shell interprets commands and executes them It provides you with an environment
More informationLinux shell programming for Raspberry Pi Users - 2
Linux shell programming for Raspberry Pi Users - 2 Sarwan Singh Assistant Director(S) NIELIT Chandigarh 1 SarwanSingh.com Education is the kindling of a flame, not the filling of a vessel. - Socrates SHELL
More informationCS Unix Tools & Scripting
Cornell University, Spring 2014 1 February 7, 2014 1 Slides evolved from previous versions by Hussam Abu-Libdeh and David Slater Regular Expression A new level of mastery over your data. Pattern matching
More informationShells and Shell Programming
Shells and Shell Programming Shells A shell is a command line interpreter that is the interface between the user and the OS. The shell: analyzes each command determines what actions are to be performed
More informationWildcards and Regular Expressions
CSCI 2132: Software Development Wildcards and Regular Expressions Norbert Zeh Faculty of Computer Science Dalhousie University Winter 2019 Searching Problem: Find all files whose names match a certain
More informationToday s Lecture. The Unix Shell. Unix Architecture (simplified) Lecture 3: Unix Shell, Pattern Matching, Regular Expressions
Lecture 3: Unix Shell, Pattern Matching, Regular Expressions Today s Lecture Review Lab 0 s info on the shell Discuss pattern matching Discuss regular expressions Kenneth M. Anderson Software Methods and
More informationScripting Languages Course 1. Diana Trandabăț
Scripting Languages Course 1 Diana Trandabăț Master in Computational Linguistics - 1 st year 2017-2018 Today s lecture Introduction to scripting languages What is a script? What is a scripting language
More informationUseful Unix Commands Cheat Sheet
Useful Unix Commands Cheat Sheet The Chinese University of Hong Kong SIGSC Training (Fall 2016) FILE AND DIRECTORY pwd Return path to current directory. ls List directories and files here. ls dir List
More informationIntroduction To. Barry Grant
Introduction To Barry Grant bjgrant@umich.edu http://thegrantlab.org Working with Unix How do we actually use Unix? Inspecting text files less - visualize a text file: use arrow keys page down/page up
More informationLecture 2. Regular Expression Parsing Awk
Lecture 2 Regular Expression Parsing Awk Shell Quoting Shell Globing: file* and file? ls file\* (the backslash key escapes wildcards) Shell Special Characters ~ Home directory ` backtick (command substitution)
More informationCS 25200: Systems Programming. Lecture 11: *nix Commands and Shell Internals
CS 25200: Systems Programming Lecture 11: *nix Commands and Shell Internals Dr. Jef Turkstra 2018 Dr. Jeffrey A. Turkstra 1 Lecture 11 Shell commands Basic shell internals 2018 Dr. Jeffrey A. Turkstra
More information5/8/2012. Exploring Utilities Chapter 5
Exploring Utilities Chapter 5 Examining the contents of files. Working with the cut and paste feature. Formatting output with the column utility. Searching for lines containing a target string with grep.
More informationComputer Systems and Architecture
Computer Systems and Architecture Stephen Pauwels Regular Expressions Academic Year 2018-2019 Outline What is a Regular Expression? Tools Anchors, Character sets and Modifiers Advanced Regular Expressions
More informationRegular Expressions 1
Regular Expressions 1 Basic Regular Expression Examples Extended Regular Expressions Extended Regular Expression Examples 2 phone number 3 digits, dash, 4 digits [[:digit:]][[:digit:]][[:digit:]]-[[:digit:]][[:digit:]][[:digit:]][[:digit:]]
More informationGetting to grips with Unix and the Linux family
Getting to grips with Unix and the Linux family David Chiappini, Giulio Pasqualetti, Tommaso Redaelli Torino, International Conference of Physics Students August 10, 2017 According to the booklet At this
More information9.2 Linux Essentials Exam Objectives
9.2 Linux Essentials Exam Objectives This chapter will cover the topics for the following Linux Essentials exam objectives: Topic 3: The Power of the Command Line (weight: 10) 3.3: Turning Commands into
More informationShell Programming Overview
Overview Shell programming is a way of taking several command line instructions that you would use in a Unix command prompt and incorporating them into one program. There are many versions of Unix. Some
More informationbash Scripting Introduction COMP2101 Winter 2019
bash Scripting Introduction COMP2101 Winter 2019 Command Lists A command list is a list of one or more commands on a single command line in bash Putting more than one command on a line requires placement
More informationUnix Internal Assessment-2 solution. Ans:There are two ways of starting a job in the background with the shell s & operator and the nohup command.
Unix Internal Assessment-2 solution 1 a.explain the mechanism of process creation. Ans: There are three distinct phases in the creation of a process and uses three important system calls viz., fork, exec,
More informationLinux shell scripting Getting started *
Linux shell scripting Getting started * David Morgan *based on chapter by the same name in Classic Shell Scripting by Robbins and Beebe What s s a script? text file containing commands executed as a unit
More informationEssentials for Scientific Computing: Bash Shell Scripting Day 3
Essentials for Scientific Computing: Bash Shell Scripting Day 3 Ershaad Ahamed TUE-CMS, JNCASR May 2012 1 Introduction In the previous sessions, you have been using basic commands in the shell. The bash
More informationCS Unix Tools & Scripting
Cornell University, Spring 2014 1 February 24, 2014 1 Slides evolved from previous versions by Hussam Abu-Libdeh and David Slater A note on awk for (item in array) The order in which items are returned
More informationCSCI 2132 Software Development. Lecture 7: Wildcards and Regular Expressions
CSCI 2132 Software Development Lecture 7: Wildcards and Regular Expressions Instructor: Vlado Keselj Faculty of Computer Science Dalhousie University 20-Sep-2017 (7) CSCI 2132 1 Previous Lecture Pipes
More informationpsed [-an] script [file...] psed [-an] [-e script] [-f script-file] [file...]
NAME SYNOPSIS DESCRIPTION OPTIONS psed - a stream editor psed [-an] script [file...] psed [-an] [-e script] [-f script-file] [file...] s2p [-an] [-e script] [-f script-file] A stream editor reads the input
More informationComputer Systems and Architecture
Computer Systems and Architecture Regular Expressions Bart Meyers University of Antwerp August 29, 2012 Outline What? Tools Anchors, character sets and modifiers Advanced Regular expressions Exercises
More informationCOMP 4/6262: Programming UNIX
COMP 4/6262: Programming UNIX Lecture 12 shells, shell programming: passing arguments, if, debug March 13, 2006 Outline shells shell programming passing arguments (KW Ch.7) exit status if (KW Ch.8) test
More informationReview of Fundamentals
Review of Fundamentals 1 The shell vi General shell review 2 http://teaching.idallen.com/cst8207/14f/notes/120_shell_basics.html The shell is a program that is executed for us automatically when we log
More informationBasics. I think that the later is better.
Basics Before we take up shell scripting, let s review some of the basic features and syntax of the shell, specifically the major shells in the sh lineage. Command Editing If you like vi, put your shell
More informationRegular Expressions. Todd Kelley CST8207 Todd Kelley 1
Regular Expressions Todd Kelley kelleyt@algonquincollege.com CST8207 Todd Kelley 1 Our standard.bashrc and.bash_profile (or.profile) Our standard script header Regular Expressions 2 [ -z "${PS1-}" ] &&
More informationChapter 4. Unix Tutorial. Unix Shell
Chapter 4 Unix Tutorial Users and applications interact with hardware through an operating system (OS). Unix is a very basic operating system in that it has just the essentials. Many operating systems,
More informationScripting. More Shell Scripts. Adapted from Practical Unix and Programming Hunter College
Scripting More Shell Scripts Adapted from Practical Unix and Programming Hunter College Copyright 2006 2009 Stewart Weiss Back to shell scripts Now that you've learned a few commands and can edit files,
More informationTopic 4: Grep, Find & Sed
Topic 4: Grep, Find & Sed grep: a tool for searching for strings within files find: a tool for examining a directory tree sed: a tool for "batch editing" Associated topic: regular expressions 1 Motivation
More informationbash, part 3 Chris GauthierDickey
bash, part 3 Chris GauthierDickey More redirection As you know, by default we have 3 standard streams: input, output, error How do we redirect more than one stream? This requires an introduction to file
More informationIntroduction to UNIX Part II
T H E U N I V E R S I T Y of T E X A S H E A L T H S C I E N C E C E N T E R A T H O U S T O N S C H O O L of H E A L T H I N F O R M A T I O N S C I E N C E S Introduction to UNIX Part II For students
More informationRegular Expressions. Regular Expression Syntax in Python. Achtung!
1 Regular Expressions Lab Objective: Cleaning and formatting data are fundamental problems in data science. Regular expressions are an important tool for working with text carefully and eciently, and are
More informationRegular Expressions. Regular expressions are a powerful search-and-replace technique that is widely used in other environments (such as Unix and Perl)
Regular Expressions Regular expressions are a powerful search-and-replace technique that is widely used in other environments (such as Unix and Perl) JavaScript started supporting regular expressions in
More informationUnix Tools / Command Line
Unix Tools / Command Line An Intro 1 Basic Commands / Utilities I expect you already know most of these: ls list directories common options: -l, -F, -a mkdir, rmdir make or remove a directory mv move/rename
More informationA Brief Introduction to the Linux Shell for Data Science
A Brief Introduction to the Linux Shell for Data Science Aris Anagnostopoulos 1 Introduction Here we will see a brief introduction of the Linux command line or shell as it is called. Linux is a Unix-like
More informationIntroduction to UNIX. Introduction. Processes. ps command. The File System. Directory Structure. UNIX is an operating system (OS).
Introduction Introduction to UNIX CSE 2031 Fall 2012 UNIX is an operating system (OS). Our goals: Learn how to use UNIX OS. Use UNIX tools for developing programs/ software, specifically shell programming.
More informationIntroduction to UNIX. CSE 2031 Fall November 5, 2012
Introduction to UNIX CSE 2031 Fall 2012 November 5, 2012 Introduction UNIX is an operating system (OS). Our goals: Learn how to use UNIX OS. Use UNIX tools for developing programs/ software, specifically
More informationPart 1: Basic Commands/U3li3es
Final Exam Part 1: Basic Commands/U3li3es May 17 th 3:00~4:00pm S-3-143 Same types of questions as in mid-term 1 2 ls, cat, echo ls -l e.g., regular file or directory, permissions, file size ls -a cat
More informationCSCI 2132 Software Development. Lecture 8: Introduction to C
CSCI 2132 Software Development Lecture 8: Introduction to C Instructor: Vlado Keselj Faculty of Computer Science Dalhousie University 21-Sep-2018 (8) CSCI 2132 1 Previous Lecture Filename substitution
More informationCS214-AdvancedUNIX. Lecture 2 Basic commands and regular expressions. Ymir Vigfusson. CS214 p.1
CS214-AdvancedUNIX Lecture 2 Basic commands and regular expressions Ymir Vigfusson CS214 p.1 Shellexpansions Let us first consider regular expressions that arise when using the shell (shell expansions).
More informationUNIX Shell Programming
$!... 5:13 $$ and $!... 5:13.profile File... 7:4 /etc/bashrc... 10:13 /etc/profile... 10:12 /etc/profile File... 7:5 ~/.bash_login... 10:15 ~/.bash_logout... 10:18 ~/.bash_profile... 10:14 ~/.bashrc...
More informationCSE 374 Midterm Exam Sample Solution 2/6/12
Question 1. (12 points) Suppose we have the following subdirectory structure inside the current directory: docs docs/friends docs/friends/birthdays.txt docs/friends/messages.txt docs/cse374 docs/cse374/notes.txt
More informationThe Unix Shell & Shell Scripts
The Unix Shell & Shell Scripts You should do steps 1 to 7 before going to the lab. Use the Linux system you installed in the previous lab. In the lab do step 8, the TA may give you additional exercises
More informationShell Programming Systems Skills in C and Unix
Shell Programming 15-123 Systems Skills in C and Unix The Shell A command line interpreter that provides the interface to Unix OS. What Shell are we on? echo $SHELL Most unix systems have Bourne shell
More informationCSE 390a Lecture 7. Regular expressions, egrep, and sed
CSE 390a Lecture 7 Regular expressions, egrep, and sed slides created by Marty Stepp, modified by Jessica Miller and Ruth Anderson http://www.cs.washington.edu/390a/ 1 2 Lecture summary regular expression
More informationPerl and R Scripting for Biologists
Perl and R Scripting for Biologists Lukas Mueller PLBR 4092 Course overview Linux basics (today) Linux advanced (Aure, next week) Why Linux? Free open source operating system based on UNIX specifications
More informationBasic UNIX Commands BASIC UNIX COMMANDS. 1. cat command. This command is used to create a file in unix. Syntax: $ cat filename
Basic UNIX Commands BASIC UNIX COMMANDS 1. cat This is used to create a file in unix. $ cat >filename This is also used for displaying contents in a file. $ cat filename 2. ls It displays the list of files
More informationRegex Guide. Complete Revolution In programming For Text Detection
Regex Guide Complete Revolution In programming For Text Detection What is Regular Expression In computing, a regular expressionis a specific pattern that provides concise and flexible means to "match"
More informationCOMS 6100 Class Notes 3
COMS 6100 Class Notes 3 Daniel Solus September 1, 2016 1 General Remarks The class was split into two main sections. We finished our introduction to Linux commands by reviewing Linux commands I and II
More informationBasic UNIX Commands BASIC UNIX COMMANDS. 1. cat command. This command is used to create a file in unix. Syntax: $ cat filename
Basic UNIX Commands BASIC UNIX COMMANDS 1. cat command This command is used to create a file in unix. $ cat >filename This command is also used for displaying contents in a file. $ cat filename 2. ls command
More information(Refer Slide Time: 01:12)
Internet Technology Prof. Indranil Sengupta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture No #22 PERL Part II We continue with our discussion on the Perl
More informationCSCI 2132: Software Development
CSCI 2132: Software Development Lab 4/5: Shell Scripting Synopsis In this lab, you will: Learn to work with command-line arguments in shell scripts Learn to capture command output in variables Learn to
More informationINTRODUCTION TO SHELL SCRIPTING ITPART 2
INTRODUCTION TO SHELL SCRIPTING ITPART 2 Dr. Jeffrey Frey University of Delaware, version 2 GOALS PART 2 Shell plumbing review Standard files Redirection Pipes GOALS PART 2 Command substitution backticks
More informationRegular Expressions Overview Suppose you needed to find a specific IPv4 address in a bunch of files? This is easy to do; you just specify the IP
Regular Expressions Overview Suppose you needed to find a specific IPv4 address in a bunch of files? This is easy to do; you just specify the IP address as a string and do a search. But, what if you didn
More informationShell Programming. Introduction to Linux. Peter Ruprecht Research CU Boulder
Introduction to Linux Shell Programming Peter Ruprecht peter.ruprecht@colorado.edu www.rc.colorado.edu Downloadable Materials Slides and examples available at https://github.com/researchcomputing/ Final_Tutorials/
More informationIntroduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines
Introduction to UNIX Logging in Basic system architecture Getting help Intro to shell (tcsh) Basic UNIX File Maintenance Intro to emacs I/O Redirection Shell scripts Logging in most systems have graphical
More informationUnix Scripts and Job Scheduling. Overview. Running a Shell Script
Unix Scripts and Job Scheduling Michael B. Spring Department of Information Science and Telecommunications University of Pittsburgh spring@imap.pitt.edu http://www.sis.pitt.edu/~spring Overview Shell Scripts
More informationUnix Shell scripting. Dr Alun Moon 7th October Introduction. Notation. Spaces
Unix Shell scripting Dr Alun Moon 7th October 2017 Introduction Shell scripts in Unix are a very powerfull tool, they form much of the standard system as installed. What are these good for? So many file
More information