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.

Slides:



Advertisements
Similar presentations
A Guide to Unix Using Linux Fourth Edition
Advertisements

CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
Introducing the Command Line CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.
Now, return to the Unix Unix shells: Subshells--- Variable---1. Local 2. Environmental.
Linux+ Guide to Linux Certification, Second Edition
Guide To UNIX Using Linux Third Edition
Lecture 02CS311 – Operating Systems 1 1 CS311 – Lecture 02 Outline UNIX/Linux features – Redirection – pipes – Terminating a command – Running program.
Unix Filters Text processing utilities. Filters Filter commands – Unix commands that serve dual purposes: –standalone –used with other commands and pipes.
Shell Script Examples.
Using Macs and Unix Nancy Griffeth January 6, 2014 Funding for this workshop was provided by the program “Computational Modeling and Analysis of Complex.
Introduction to Linux Workshop February Introduction Rob Lane & The HPC Support Team Research Computing Services CUIT.
Advanced File Processing
1 THE UNIX FILE SYSTEM By Chokechai Chuensukanant ID COSC 513 Operating System.
UNIX command line. In this module you will learn: What is the computer shell What is the command line interface (or Terminal) What is the filesystem tree.
Lesson 7-Creating and Changing Directories. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files.
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
Chapter Four UNIX File Processing. 2 Lesson A Extracting Information from Files.
Guide To UNIX Using Linux Fourth Edition
Introduction to Unix (CA263) File Processing. Guide to UNIX Using Linux, Third Edition 2 Objectives Explain UNIX and Linux file processing Use basic file.
An Introduction to Unix Shell Scripting
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.
Linux+ Guide to Linux Certification, Third Edition
Session 2 Wharton Summer Tech Camp Basic Unix. Agenda Cover basic UNIX commands and useful functions.
Week 3 Exploring Linux Filesystems. Objectives  Understand and navigate the Linux directory structure using relative and absolute pathnames  Describe.
OPERATING SYSTEMS DESIGN UNIX BASICS & SHELL SCRIPTING.
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.
UNIX Shell Script (1) Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology
Chapter Five Advanced File Processing Guide To UNIX Using Linux Fourth Edition Chapter 5 Unix (34 slides)1 CTEC 110.
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 and Using Linux Topics What is an Operating System? Linux Overview Frequently Used Linux Commands Some content in this lecture added.
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.
ITR3 lecture 6: intoduction to UNIX Thomas Krichel
INFO 320 Server Technology I Week 5 Shell environments and scripting 1INFO 320 week 5.
Chapter Five Advanced File Processing. 2 Lesson A Selecting, Manipulating, and Formatting Information.
Introduction to Programming Using C An Introduction to Operating Systems.
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
– Introduction to the Shell 1/21/2016 Introduction to the Shell – Session Introduction to the Shell – Session 3 · Job control · Start,
Linux+ Guide to Linux Certification, Second Edition Chapter 4 Exploring Linux Filesystems.
ORAFACT Text Processing. ORAFACT Searching Inside Files grep - searches for patterns within files grep [options] [[-e] pattern] filename [...] -n shows.
Operating Systems and Using Linux Courtesy of John Y. Park 1.
CS 403: Programming Languages Lecture 20 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
1 Lecture 7 Introduction to Shell Scripts COP 3353 Introduction to UNIX.
Unix Lab Fall Shell Scripting ●Through the shell (LXTerminal) you can: ●Run programs. ●Interact with the file system. ●Change settings. ●Send/receive.
Learning Unix/Linux Based on slides from: Eric Bishop.
INTRODUCTION TO SHELL SCRIPTING By Byamukama Frank
Working with command-line systems and GAMIT/GLOBK M. A. Floyd T. A. Herring Massachusetts Institute of Technology GAMIT/GLOBK/TRACK Short Course for GPS.
Tutorial of Unix Command & shell scriptS 5027
Lesson 5-Exploring Utilities
Working with command-line systems and GAMIT/GLOBK
The UNIX Shell Learning Objectives:
Working with command-line systems and GAMIT/GLOBK
Part 1: Basic Commands/Utilities
Some Linux Commands.
Shell Script Assignment 1.
Introduction to UNIX Directory structure and navigation
Tutorial of Unix Command & shell scriptS 5027
Basic UNIX OLC Training.
Introduction to UNIX.
Tutorial of Unix Command & shell scriptS 5027
Working with command-line systems and GAMIT/GLOBK
John Carelli, Instructor Kutztown University
Guide To UNIX Using Linux Third Edition
Tutorial of Unix Command & shell scriptS 5027
Chapter Four UNIX File Processing.
Working with command-line systems and GAMIT/GLOBK
Chapter 3 The UNIX Shells
Working with command-line systems and GAMIT/GLOBK
Presentation transcript:

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 structure and navigation Using a command line Commands to know Introduction to shell scripts

Quick poll Who is using what type of operating system? – Linux (flavor?) – Mac OS X – Windows Who has installed the software successfully? Who has run the example successfully?

Directory structure and navigation

Directory structures One must be familiar with the layout of files and directories (or “folders”) Once one has a mental “map” of the directory structure, navigating between directories and finding files is easier Think of it as a filing cabinet or family tree /1a2a2b3a3b1b2c1c2d3c3d

Directory structures Top-level (“root”) directory (“/” on UNIX, “C:\” on Windows, etc.) User’s current working directory is referred to by the shorthand “.” [period] The “parent” directory is one level above the current working directory in the hierarchy Parent directory is referred to by the shorthand “..” [double period] /1a2a2b3a3b1b2c1c2d3c3d

Changing directory Once user knows where they are with “mental map” of directory structure, move around. We can move up or down the hierarchy but not sideways. cd / – Takes user to top-level (“root”) directory cd 1b – Takes user to “1b” directory in first level (move down hierarchy) cd 2c – Takes user to “2c” directory in second level, below “1b” (move down hierarchy) cd 2d – Unknown directory. Why? – User attempting to move sideways but “2c” not connected directly to “2d”. /1a2a2b3a3b1b2c1c2d3c3d

Absolute paths To move back up the hierarchy to “2d”, one may explicitly start from the top level, e.g. cd / cd 1c cd 2d or, combined, simply cd /1c/2d – Directories are separated by forward slashes /1a2a2b3a3b1b2c1c2d3c3d

Relative paths Or: Move back up to “1b” –cd.. Move back up to “/” –cd.. Move down to “1c” –cd 1c Move down to “2d” –cd 2d Or, combined, simply: –cd../../1c/2d /1a2a2b3a3b1b2c1c2d3c3d

Using a command line

UNIX commands Basic syntax is: – is the program to run, including path if not included in PATH environment variable (more in a couple of slides…) are usually prepended by a dash (e.g. -a) are usually input or output files to work on Commands may or may not have options or expect arguments

Basic commands cd – Change directory, for navigating the directory structure pwd – Print working directory, to know where you are ls – List directories and files in current working directory (“.”) or directory given after command Use the “tab” key to auto-complete options

Environment variables A computer must be told information in order to work the way you expect Many important settings are kept in “environment variables” – $HOME = user’s home directory – $PATH = list of directories containing programs – $SHELL = user’s command shell env – Prints information on environment variables

Local variables To make life easier, one may also set local variables, which may be referred back to at any time Useful if one finds the need to write the same thing may times sh/bash: –var=‘Hello’ – Instead of writing ‘Hello’, any reference to $var will be equivalent ‘Hello’ –var=( Hello Goodbye ) – Any reference to ${var[0]} will be equivalent to ‘Hello’ and ${var[1]} to ‘Goodbye’ csh/tcsh: –set var = ‘Hello’ – Instead of writing ‘Hello’, any reference to $var will be equivalent to ‘Hello’ –set var = ( Hello Goodbye ) – Any reference to $var[1] will be equivalent to ‘Hello’ and $var[2] to goodbye

Commands to know

Everyday commands awk grep sed sort paste/join tr echo/cat

awk Powerful formatted read/write utility, e.g. awk ‘{print $1,$2,$3}’ – Prints first, second and third white-spaced columns (“fields”) from each line of awk –v n=3 –F’,’ ‘{print $NF/n}’ – Prints the last comma-separated field divided by 3 from each line of awk ‘BEGIN {sum=0}; {sum=sum+$1}; END {printf(“%.1f\n”,sum/NR)}’ – Calculate mean of first field: sums first field on each line then divides by number of lines (“records”)

grep Pattern-matching command (“general regular expression”) grep ‘hello’ – Prints all lines from with occurrence of “hello” in them grep –ci ‘^apr’ – Prints the number (“-c”) of lines that begin (“^”) with “apr” in either upper- or lower-case letters (“-i”) in grep ‘^.* P$’ – Print all lines in that begin (“^”) with a space, followed by any number of any characters (“.*”), and end (“$”) with a space followed by P

sed Basic text editor sed ‘s/ //g’ – Substitute (“s”) all (“g”) instances of a single whitespace with nothing (i.e. delete all whitespace) sed ‘/^ *$/d; s/hello/goodbye/1’ – Delete (“d”) all empty lines and substitute the first instance of “hello” with “goodbye” on each line of

sort Sorts records sort – Outputs basic alpha-numerically ordered sort –u – Same as above but uniquely sorted (i.e. removes duplicate records) sort –gk3 – General numeric ordering based on third field of sort –uk2.1,2.4 – Sort based on first character of second field to fourth character of second field and use this as the basis for the uniqueness test

tr Basic translation tr ‘[:upper:]’ ‘[:lower:]’ – Transposes all upper-case letters to lower-case tr –d ‘\r’ – Deletes all carriage return (“CR”) characters (useful for changing a file’s line ending from DOS to UNIX format)

echo/cat Echoes the argument echo ‘Help!’ – Prints “Help!” cat – Reads out entirety of cat << END Help! END – Same as “echo ‘Help!’”

Redirection The output from one command may be written to a file… – “>” to overwrite an existing file – “>>” to append to an existing file –sort [file] > [sorted file] …or “piped” to another command, effectively forming the second command’s input – “|” –grep ‘^.* P$’ [file] | sort > [grep’d and sorted file]

Shorthands Top-level (“root”) directory = “/”, e.g. –cd / Your home directory = “~” or “$HOME”, e.g. –ls ~ “Links” or “shortcuts” may be created, e.g. –ln –s /usr/local/gg/10.4 ~/gg This creates a link in the user’s home directory called “gg” that points to the directory /usr/local/gg/10.4 – Rather than cd /usr/local/gg/10.4, one can get to the same place simply with cd ~/gg – (This is used in GAMIT-GLOBK scripts and must remain in place!)

Useful commands du – Disk usage: useful if you want to know how much space your (or others’!) directories are taking up df – Disk free space: useful if you want to know how much disk space is used and free top – Table Of Processes: useful if you want a real-time overview of running processes ps – List processes: useful if you want to see what processes are running and their process numbers, commands, etc.

Introduction to shell scripts

What is a script? Scripts contain a series of commands written in one file and prepended by a “hashbang” –#!/bin/sh for original Bourne Shell (usually the same as bash on modern systems) –#!/bin/bash for Bourne Again Shell –#!/bin/csh for C Shell (usually the same as tcsh on modern systems) –#!/bin/tcsh for TENEX C Shell The script may then be executed to run all of the commands in sequence as written

Script example #!/bin/bash echo –n ‘The ISO date is: ‘ date +‘%Y-%m-%dT%H:%M:%S%Z’ echo –n ‘The mean of all numbers between 1 and 10 is: ’ echo 1 10 | awk ‘BEGIN {sum=0; n=0}; {for (i=$1; i<=$2; i++) {sum=sum+i; n++}}; END {print sum/n}’ echo ‘Goodbye!’