Bash Shell Programming Helps

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

CS Unix Tools & Scripting

Essentials for Scientific Computing: Bash Shell Scripting Day 3

Useful Unix Commands Cheat Sheet

Bash scripting basics

Introduction: What is Unix?

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

Essential Unix and Linux! Perl for Bioinformatics, ! F. Pineda

Using bash. Administrative Shell Scripting COMP2101 Fall 2017

CSE 15L Winter Midterm :) Review

A shell can be used in one of two ways:

5/20/2007. Touring Essential Programs

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

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

Basic Linux (Bash) Commands

COMP 4/6262: Programming UNIX

Introduction to the shell Part II

Scripting. More Shell Scripts Loops. Adapted from Practical Unix and Programming Hunter College

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

CSCI 211 UNIX Lab. Shell Programming. Dr. Jiang Li. Jiang Li, Ph.D. Department of Computer Science

Processes and Shells

Linux shell programming for Raspberry Pi Users - 2

Topic 2: More Shell Skills

CSCI 2132: Software Development. Norbert Zeh. Faculty of Computer Science Dalhousie University. Shell Scripting. Winter 2019

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

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.

Linux Shell Scripting. Linux System Administration COMP2018 Summer 2017

Bourne Shell Reference

OPERATING SYSTEMS LAB LAB # 6. I/O Redirection and Shell Programming. Shell Programming( I/O Redirection and if-else Statement)

bash Args, Signals, Functions Administrative Shell Scripting COMP2101 Fall 2017

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

LING 408/508: Computational Techniques for Linguists. Lecture 5

Mills HPC Tutorial Series. Linux Basics II

9.2 Linux Essentials Exam Objectives

Assignment 1: Communicating with Programs

Shell Programming Systems Skills in C and Unix

Introduction Variables Helper commands Control Flow Constructs Basic Plumbing. Bash Scripting. Alessandro Barenghi

Bash scripting Tutorial. Hello World Bash Shell Script. Super User Programming & Scripting 22 March 2013

Title:[ Variables Comparison Operators If Else Statements ]

Command Interpreters. command-line (e.g. Unix shell) On Unix/Linux, bash has become defacto standard shell.

UNIX System Programming Lecture 3: BASH Programming

Shell Start-up and Configuration Files

Shell Programming (Part 2)

Introduction to Linux Basics Part II. Georgia Advanced Computing Resource Center University of Georgia Suchitra Pakala

CSC 2500: Unix Lab Fall 2016

Topic 2: More Shell Skills

Lecture 5. Essential skills for bioinformatics: Unix/Linux

Lab 3 : Sort program

Vi & Shell Scripting

Command-line interpreters

Bashed One Too Many Times. Features of the Bash Shell St. Louis Unix Users Group Jeff Muse, Jan 14, 2009

Shell Scripting. With Applications to HPC. Edmund Sumbar Copyright 2007 University of Alberta. All rights reserved

Assignment clarifications

Review of Fundamentals

CS 2505 Computer Organization I Test 1

(a) About Unix. History

Shell Scripting. Todd Kelley CST8207 Todd Kelley 1

Lab 2: Linux/Unix shell

SHELL SCRIPT BASIC. UNIX Programming 2014 Fall by Euiseong Seo

Introduction To. Barry Grant

Topic 2: More Shell Skills. Sub-Topic 1: Quoting. Sub-Topic 2: Shell Variables. Difference Between Single & Double Quotes

Unix Shell. Advanced Shell Tricks

Understanding bash. Prof. Chris GauthierDickey COMP 2400, Fall 2008

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

1. Hello World Bash Shell Script. Last Updated on Wednesday, 13 April :03

bash Args, Signals, Functions Administrative Shell Scripting COMP2101 Fall 2018

COMP 2718: Shell Scripts: Part 1. By: Dr. Andrew Vardy

CS 2505 Computer Organization I Test 1

Open up a terminal, make sure you are in your home directory, and run the command.

The Unix Shell & Shell Scripts

Shell script. Shell Scripts. A shell script contains a sequence of commands in a text file. Shell is an command language interpreter.

Computer Systems and Architecture

CST Algonquin College 2

Shell script/program. Basic shell scripting. Script execution. Resources. Simple example script. Quoting

SHELL SCRIPT BASIC. UNIX Programming 2015 Fall by Euiseong Seo

BASH Programming Introduction

PROGRAMMAZIONE I A.A. 2015/2016

Introduction to the Shell

Command Line Interface Techniques

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

DAVE LIDDAMENT INTRODUCTION TO BASH

I/O and Shell Scripting

CSCI 2132 Software Development. Lecture 5: File Permissions

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

5/8/2012. Exploring Utilities Chapter 5

Shell Programming. Introduction to Linux. Peter Ruprecht Research CU Boulder

CS 307: UNIX PROGRAMMING ENVIRONMENT KATAS FOR EXAM 2

Module 8 Pipes, Redirection and REGEX

QUESTION BANK ON UNIX & SHELL PROGRAMMING-502 (CORE PAPER-2)

What is Bash Shell Scripting?

RHCE BOOT CAMP. System Administration

Chapter 9. Shell and Kernel

Essential Skills for Bioinformatics: Unix/Linux

Shells and Shell Programming

Computer Systems and Architecture

EECS2301. Lab 1 Winter 2016

Advanced Linux Commands & Shell Scripting

Shell Programming (bash)

INTRODUCTION TO SHELL SCRIPTING ITPART 2

Shell scripting Scripting and Computer Environment - Lecture 5

Transcription:

Bash Shell Programming Helps We use the Bash shell to orchestrate the chip building process Bash shell calls the other tools, does vector checking The shell script is a series of commands that the Bash interpreter executes

Bash Shell Programming Helps Bash shell scripts begin with a she bang followed by the path to the bash interpreter on line one. This tells the interpreter that this file is a shell script and also where the script resides. For a script file named scriptfilename : #!/bin/bash echo "this is my first shell script" The shell script is not executable unless you make it so. The following adds execute permissions for the user. chmod u+x <scriptfilename>

Bash Shell Programming Helps - Decisions with if if [ condition_to_test ] ; then command1 elif command2 else command3 fi File based test conditions Condition True If [ -a file ] file exists [ -e file ] file exists (same as -a) [ -d directory ] directory exists and is a directory [ -f regularfile] regularfile exists and is a regular file [ -s regularfile] regularfile exists and has size >0 [ -x excutablefile] excutablefile exists and is executable by the shell

Bash Shell Programming Helps - Other test conditions Condition True If [ string1 == string2 ] string1 is equal to string2 [ string1!= string2 ] string1 is not equal to string2 [ numb1 -eq numb2 ] numb1 is equal to numb2 [ numb1 -ne numb2 ] numb1 is not equal to numb2 [ numb1 -gt numb2 ] numb1 is greater than numb2

Bash Shell Programming Helps - Running VSIM vsim is always invoked on the module name, not the source file vsim modulename not vsim modulename.sv Typical vsim invocation for use in bash scripts: vsim modulename -do dofilename -quiet -c -t 1ps Minimizes chatter from the tool Runs without the gui Sets simulator to run with 1pS resolution For more vsim command line arguments, type: vsim -help

Bash Shell Programming Helps - File Redirection In BASH, there are three standard IO streams open: stdin file handle 0 standard input stdout file handle 1 standard output stderr file handle 1 standard error redirect stdout to file.txt, creating the file if necessary cmd > file.txt forcefully redirect stdout to file.txt, even if noclobber is set cmd > file.txt redirect stdout to file.txt, appending to file.txt if it exists cmd >> file.txt redirect stdout and stderr to file.txt cmd &> file.txt pipe: send stdout of cmd1 to stdin of cmd2 cmd1 cmd2

Bash Shell Programming Helps - Variables, translate Using a string variable to shorten names OSU SYN LIB="/nfs/guille/a1/cadlibs/osu lib" Dereferencing the variable using the dollar sign vlog $OSU SYN LIB/lib ss 1.62 125c.v -work work Translate lower case to uppercase in a list file using temporary file cat listfile tr [a-z][a-z] > $$tempfile mv $$temfile listfile cat sends the contents of listfile via a pipe into the translate utility tr. tr does the substitution and puts the results into a temporary file called $$tempfile. Then, $$tempfile is renamed to listfile with the altered contents.

Bash Shell Programming Helps - Tee Sometimes you want to see the output of a compile on the screen and also also have it sent to a file. The utility tee does this for you. For example: vlog my module.sv tee compile transcript sends the output from vlog to the file named compile transcript and also routes it to the screen.

Bash Shell Programming Helps - regression, diff, comments Check output vectors against a set of known good golden vectors. if [! -s "golden_vectors" ]; then echo "no golden vectors found" exit #bug out of shell else diff listfile golden_vectors > reports/miscompares fi A check can then be made on the size of the miscompares file to see if there were any miscompares.

Bash Shell Programming Helps - good links For more information, see: http://tldp.org/ldp/bash-beginners-guide/html/bash-beginners-guide.html http://tldp.org/howto/bash-prog-intro-howto.html