Common File System Commands

Similar documents
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

CS246 Spring14 Programming Paradigm Files, Pipes and Redirection

UNIX Shell Programming

Week Overview. Simple filter commands: head, tail, cut, sort, tr, wc grep utility stdin, stdout, stderr Redirection and piping /dev/null file

5/8/2012. Exploring Utilities Chapter 5

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

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.

The Unix Shell. Pipes and Filters

Topic 2: More Shell Skills

Software I: Utilities and Internals. What isbash?

Scripting Languages Course 1. Diana Trandabăț

Introduction To Linux. Rob Thomas - ACRC

UNIX Essentials Featuring Solaris 10 Op System

Useful Unix Commands Cheat Sheet

The UNIX Shells. Computer Center, CS, NCTU. How shell works. Unix shells. Fetch command Analyze Execute

CSE 390a Lecture 2. Exploring Shell Commands, Streams, and Redirection

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

LOG ON TO LINUX AND LOG OFF

Sub-Topic 1: Quoting. Topic 2: More Shell Skills. Sub-Topic 2: Shell Variables. Referring to Shell Variables: More

Linux Shell Script. J. K. Mandal

Introduction to UNIX. Introduction. Processes. ps command. The File System. Directory Structure. UNIX is an operating system (OS).

Introduction to UNIX. CSE 2031 Fall November 5, 2012

Module 8 Pipes, Redirection and REGEX

Lab 2: Linux/Unix shell

Bourne Shell Reference

ITST Searching, Extracting & Archiving Data

Set 1 MCQ Which command is used to sort the lines of data in a file in reverse order A) sort B) sh C) st D) sort -r

CSE 15L Winter Midterm :) Review

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

UNIX Tutorial Two

Introduction to UNIX. Introduction EECS l UNIX is an operating system (OS). l Our goals:

bash, part 3 Chris GauthierDickey

Basics. I think that the later is better.

Files

CSE 390a Lecture 2. Exploring Shell Commands, Streams, Redirection, and Processes

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

Wildcards and Regular Expressions

Introduction: What is Unix?

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

Introduction to Linux. Roman Cheplyaka

Utilities. September 8, 2015

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

CST Algonquin College 2

Practical Session 0 Introduction to Linux

Unix Guide. Meher Krishna Patel. Created on : Octorber, 2017 Last updated : December, More documents are freely available at PythonDSP

Basic UNIX Commands BASIC UNIX COMMANDS. 1. cat command. This command is used to create a file in unix. Syntax: $ cat filename

Contents. Note: pay attention to where you are. Note: Plaintext version. Note: pay attention to where you are... 1 Note: Plaintext version...

CS 25200: Systems Programming. Lecture 11: *nix Commands and Shell Internals

Essential Linux Shell Commands

CSCI 2132 Software Development. Lecture 7: Wildcards and Regular Expressions

Chapter-3. Introduction to Unix: Fundamental Commands

Basic Unix Command. It is used to see the manual of the various command. It helps in selecting the correct options

Introduction to Bash Programming. Dr. Xiaolan Zhang Spring 2013 Dept. of Computer & Information Sciences Fordham University

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

for more :-

CSE 303 Lecture 2. Introduction to bash shell. read Linux Pocket Guide pp , 58-59, 60, 65-70, 71-72, 77-80

Shell Programming Overview

UNIX files searching, and other interrogation techniques

Part 1: Basic Commands/U3li3es

A Brief Introduction to the Linux Shell for Data Science

Introduction to Linux

Introduction to Unix Week 3

CST Lab #5. Student Name: Student Number: Lab section:

UNIX COMMANDS AND SHELLS. UNIX Programming 2015 Fall by Euiseong Seo

Review of Fundamentals

CHAPTER 2 THE UNIX SHELLS

LAB 8 (Aug 4/5) Unix Utilities

A Brief Introduction to Unix

Introduction to Unix: Fundamental Commands

Topic 2: More Shell Skills

Reading and manipulating files

5/20/2007. Touring Essential Programs

22-Sep CSCI 2132 Software Development Lecture 8: Shells, Processes, and Job Control. Faculty of Computer Science, Dalhousie University

Unix 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.

On successful completion of the course, the students will be able to attain CO: Experiment linked. 2 to 4. 5 to 8. 9 to 12.

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

Shells. A shell is a command line interpreter that is the interface between the user and the OS. The shell:

More Scripting and Regular Expressions. Todd Kelley CST8207 Todd Kelley 1

Topic 4: Grep, Find & Sed

find Command as Admin Security Tool

M2PGER FORTRAN programming. General introduction. Virginie DURAND and Jean VIRIEUX 10/13/2013 M2PGER - ALGORITHME SCIENTIFIQUE

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

Title:[ Variables Comparison Operators If Else Statements ]

Basic Linux (Bash) Commands

Prof. Navrati Saxena TA: R. Sachan

Software I: Utilities and Internals. What is UNIX?

2) clear :- It clears the terminal screen. Syntax :- clear

Unix as a Platform Exercises + Solutions. Course Code: OS 01 UNXPLAT

The Directory Structure

UNIX Basics. UNIX Basics CIS 218 Oakton Community College

Basic UNIX Commands BASIC UNIX COMMANDS. 1. cat command. This command is used to create a file in unix. Syntax: $ cat filename

Std: XI CHAPTER-3 LINUX

Command-line interpreters

Review of Fundamentals. Todd Kelley CST8207 Todd Kelley 1

Appendix B WORKSHOP. SYS-ED/ Computer Education Techniques, Inc.

Linux environment. Graphical interface X-window + window manager. Text interface terminal + shell

Shell Programming for System Administrators Student Guide

Command Line Interface The basics

Linux shell programming for Raspberry Pi Users - 2

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

Transcription:

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. Also ls -lt! ls -t! List by time last used. Also ls -lu, ls -lut! ls -r! List in reverse order. Also ls -rt, ls -rlt, etc! ed filename! Edit named file cp file1 file2! Copy file1 file2. Overwrite old file2 if it exists mv file1 file2! Move file1 file2. Overwrite old file2 if it exists rm filenames! Remove named files, irrevocably cat filenames! Print contents of named files pr filenames! Print content with header, 66 lines per pages (default) pr -n filenames! Print in n columns pr -m filenames! Print named files side by side in multiple columns wc filenames! Count lines, words, and characters for each file wc -l filenames! Count lines for each file grep pattern filenames! Print lines matching pattern grep -v pattern filenames! Print lines not matching pattern sort filenames! Sort files alphabetically by line tail filename! Print last 10 lines of file tail -n filename! Print last n lines of file tail +n filename! Start printing file at line n cmp file1 file2! Print location of first difference diff file1 file2! Print all differences between files

Shell Metacharacters >! prog > file direct standard output to file >>! prog >> file append standard output to file <! prog < file take standard input from file! p 1 p 2 connect standard output of p 1 to standard input of p 2 <<here! here document: standard input follows, up to next here on a line by itself! *! Match any string of zero or more characters in filenames!?! Match any single character in filenames [ccc]! Match any single character from [ccc] in filenames. Ranges like 0-9 or a-z are legal ;! Command terminator: p 1 ; p 2 does p 1, then p 2 &! Like ; but does not wait for p 1 to finish ` `! ( )! { }! Run command(s) in ; output replaces ` `! Run command(s) in in a sub-shell! Run command(s) in in current shell (rarely used) $1, $2, etc $0 $9 replaced by arguments to shell file $var! ${var}! Value of shell variable var Value of var; avoids confusion when concatenated with text \! \c take character c literally, \newline discarded!! Take literally Take literally after $, ` ` and \ interpreted #! Text after # is a comment var=value! Assign value to variable var p 1 && p 2 Run p 1 ; if successful, run p 2 p 1 p 2 Run p 1 ; if unsuccessful, run p 2

Shell I/O Redirections > file direct standard output to file >> file append standard output to file < file take standard input from file p 1 p 2 connect standard output of program p 1 to input of p 2 ^! obsolete synonym for! n>file n>>file direct output from file descriptor n to file! append output from file descriptor n to file! n>&m merge output from file descriptor n with file descriptor m! n<&m merge input from file descriptor n with file descriptor m! <<s <<\s << s here document: take standard input until next s at beginning of a line; substitute for $, ` `, and \ here document with no substitution here document with no substitution

grep and egrep Regular Expressions (decreasing order of precedence) c any non-special character c matches itself \c turn off any special meaning of character c ^! beginning of line! $! end of line!.! any single character! [ ]! any one of characters in ; ranges like a-z are legal! [^ ]! any single character not in ; ranges are legal! \n what the n th \( \) matched (grep only) r* zero or more occurrences of r r+ one or more occurrences of r (egrep only) r? zero or more occurrences of r (egrep only) r 1 r 2 r 1 followed by r 2 r 1 r 2 r 1 or r 2 (egrep only) \(r\)! tagged regular expression r (grep only); can be nested (r)! regular expression r (egrep only); can be nested No regular expression matches a newline.

Shell Built-in Variables $# the number of arguments $* all arguments to shell. $* is a single word! $@ similar to $*. $@ is identical to the list of the arguments to shell $- options supplied to the shell $? return value of the last command executed $$ process-id of the shell $! process-id of the last command started with & $HOME default argument for cd command $IFS list of characters that separate words in arguments $MAIL file that, when changed, triggers you have mail message $PATH list of directories to search for commands $PS1 prompt string, default $ $PS2 prompt string for continued command line, default >

Shell Pattern Matching Rules *! match any string, including the null string!?! match any single character [ccc]!! \c! a b! match any of the characters in ccc [a-d0-3] is equivalent to [abcd0123] match exactly; quotes protect special characters. Also match c literally in case espressions only, matches either a or b / in filenames, matched only by an explicit / in the expression; in case, matched like any other character. as the first character of a filename, is matched only by an explicit. in the expression