Using Linux Commands Lab 4 1. Create empty files To create an empty file $ touch apple banana grape grapefruit watermelon $ ls -l Using file-matching.

Slides:



Advertisements
Similar presentations
Linux Shell Script. Shell script The first line is used to specify shell program #!/bin/sh Variables variable=“text” variable=0 variable=`program arguments`
Advertisements

CIS 118 – Intro to UNIX Shells 1. 2 What is a shell? Bourne shell – Developed by Steve Bourne at AT&T Korn shell – Developed by David Korn at AT&T C-shell.
Introduction to UNIX CSE 2031 Fall May 2015.
The Unix File System. What are the three parts of every file on a Unix filesystem? And where is each stored? Filename - stored in directories Inode -
Linux+ Guide to Linux Certification, Second Edition
Shell Basics CS465 - Unix. Shell Basics Shells provide: –Command interpretation –Multiple commands on a single line –Expansion of wildcard filenames –Redirection.
Now, return to the Unix Unix shells: Subshells--- Variable---1. Local 2. Environmental.
CS 497C – Introduction to UNIX Lecture 20: - The Shell Chin-Chih Chang
Linux File Security. What is Permission ? Specifies what right are granting to users to access the resources available in the computer. So that important.
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)
Using Linux Commands 2 Lab#5
Shell Script Examples.
Using Linux Commands 2 Lab#5. Sort command Sort the lines of text files. $ sort fileName by default it will sort in normal order(alphabetical 0-9 A-Z.
1 Lecture 2 Working with Files and Directories COP 3344 Introduction to UNIX.
Chapter Nine Advanced Shell Scripting1 System Programming Advanced Shell Scripting.
Week 7 Working with the BASH Shell. Objectives  Redirect the input and output of a command  Identify and manipulate common shell environment variables.
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
Some simple examples First, second, third(with errors) third2.
Unix Shells Based on Glass & Abels’ Book CS240 Computer Science II.
An Introduction to Unix Shell Scripting
Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 5.1 © Copyright IBM Corporation 2008 Unit 8 Shell.
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.
Introduction to Java Thanks to Dan Lunney (SHS). Java Basics File names The “main” method Output to screen Escape Sequence – Special Characters format()
The Shell Chapter 7. Overview The Command Line Standard IO Redirection Pipes Running a Program in the Background Killing (a process!)
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.
Introduction to Linux OS (IV) AUBG ICoSCIS Team Prof. Volin Karagiozov March, 09 – 10, 2013 SWU, Blagoevgrad.
OPERATING SYSTEMS DESIGN UNIX BASICS & SHELL SCRIPTING.
Introduction to Bash Programming Ellen Zhang. Previous three classes What have we learnt so far ?
Linux+ Guide to Linux Certification, Third Edition
UNIX Shell Script (1) Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology
Workbook 6 – Part 2 The Bash Shell
Linux+ Guide to Linux Certification Chapter Eight Working with the BASH Shell.
Lesson 2 1.Commands 2.Filename Substitution 3.I/O Redirection 4.Command Grouping 5.Shell Responisibilites Review of the Basics.
Unix/Linux cs3353. The Shell The shell is a program that acts as the interface between the user and the kernel. –The shell is fully programmable and will.
Shell Advanced Features. Module 8 Shell Advanced Features ♦ Introduction In Linux systems, the shells are often referred to as command line interfaces.
(A Very Short) Introduction to Shell Scripts CSCI N321 – System and Network Administration Copyright © 2000, 2003 by Scott Orr and the Trustees of Indiana.
Introduction to Linux Instructor: Bennett M. Tanyag PART – 3 Unit 1.
Intro to UNIX Presented by: Student Ambassadors: Lauren Lewis Martin Sung.
LIN Unix Lecture 5 Unix Shell Scripts. LIN Command Coordination ; && || command1 ; command2 Interpretation: Do command 1. Then do command.
1 © 2000 John Urrutia. All rights reserved. Session 5 The Bourne Shell.
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)
Agenda Positional Parameters / Continued... Command Substitution Bourne Shell / Bash Shell / Korn Shell Mathematical Expressions Bourne Shell / Bash Shell.
Chapter 5: The Shell The Man in the Middle. In this chapter … The command line Input, output, and redirection Process management Wildcards and expansion.
1 Lecture 2 Working with Files and Directories COP 3353 Introduction to UNIX.
CSCI 330 UNIX and Network Programming Unit III Shell, Part 1.
More Unix Naomi Altman. Directories Directory = folder mkdir - makes a new directory rmdir - removes an empty directory cd mydirectory - moves you into.
Agenda The Bourne Shell – Part II Special Characters Ambiguous File Reference Variable Names and Values User Created Variables Read-only Variables (Positional.
Sed. Class Issues vSphere Issues – root only until lab 3.
Linux+ Guide to Linux Certification, Second Edition
© Prepared By: Razif Razali 1 TMK 265: UNIX SYSTEM CHAPTER FOUR – QUOTING IN DETAIL.
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.
1 Lecture 8 Shell Programming – Control Constructs COP 3353 Introduction to UNIX.
Lesson 5-Exploring Utilities
Introduction to Shells
Commands Basic syntax of shell commands UNIX or shell commands have a basic structure command -options target command comes first (such as cd or ls) any.
Prepared by: Eng. Maryam Adel Abdel-Hady
Linux Commands Help HANDS ON TRAINING Author: Muhammad Laique
Some Linux Commands.
Shell Scripting March 1st, 2004 Class Meeting 7.
CSE 303 Concepts and Tools for Software Development
Using Linux Commands Lab 3.
John Carelli, Instructor Kutztown University
The Linux Command Line Chapter 7
UNIX Reference Sheets CSE 2031 Fall 2010.
Linux Shell Script Programming
CSE 303 Concepts and Tools for Software Development
Module 4 Command Line Skills
Module 6 Working with Files and Directories
Introduction to Bash Programming, part 3
Presentation transcript:

Using Linux Commands Lab 4 1

Create empty files To create an empty file $ touch apple banana grape grapefruit watermelon $ ls -l Using file-matching metacharacters Metacharacters help to match one or more files without typing each filename completely.  *This matches any number of characters.  ?This matches any one character.  […]This matches any one of the characters between the brackets, which can include a dash-separated rang of letters or numbers. 2

$ ls a* apple $ ls g* grape grapefruit $ ls g*t grapefruit $ ls *e* apple grape grapefruit watermelon $ ls *n* banana watermelon Using file-matching metacharacters Using file-matching metacharacters This matches any number of characters * 3

Using file-matching metacharacters Using file-matching metacharacters This matches any one character? $ ls ????e Apple grape $ ls g???e* grape grapefruit 4

Using file-matching metacharacters Using file-matching metacharacters This matches any one of the characters between the brackets […] $ ls [abw]* apple banana watermelon $ ls [agw] * [ne] grape grapefruit $ ls [a-g] * apple banana grape grapefruit 5

Using file-redirection metacharacters $ mail root < ~/.bashrc $ echo “I finished the project on $(date)” > ~/projects Direct the contents of a file to the command < overwriting Direct the output of a command to a file, overwriting any existing file > adding Direct the output of a command to a file, adding the output to the end of existing file >> $ echo “I finished the project on $(date)” >> ~/projects 6

date commands Change or set current date and time. Syntax date [date or time string ] Examples Show current date & time Set date to 2011-Mar-15 Set date as well as time $ date $date --date=“ $date --date=“ :59 AM” 7

echo Command Use echo command to display text or value of variable. echo [options] [string, variables...] Displays text or variables value on screen. 8

echo Command Options -n Do not output the trailing new line. -e Enable interpretation of the following backslash escaped characters in the strings: \a alert (bell) \b backspace \n new line \t horizontal tab 9

Quotes "Double Quotes" - Anything enclose in double quotes removed meaning of that characters (except \ and $). 'Single quotes' - Enclosed in single quotes remains unchanged. `Back quote` - To execute command 10

Examples of quoting special characters $ echo ' My working directory is `pwd`' My working directory is`pwd` $ echo "My working directory is `pwd`” My working directory is /home/jane $ echo -e "An apple a day keeps away \a\t\tdoctor\n" 11

Sort command Piping command sort {file-name} Options -r Reverse normal order (so "Z" starts the list instead of "A"). -n Sort in numeric order -nr Sort in reverse numeric order $ ls /etc/password | sort | less 12

Sequential commands To run a sequence of commands type several commands on the same command line and separating them with semicolons(;) $ mkdir ng ; cd ng ; touch tom 13