BIF703 Miscellaneous Commands. File related commands  grep - print lines matching a pattern  head - output the first part of files  tail - output the.

Slides:



Advertisements
Similar presentations
Jump to first page Unix Commands Monica Stoica Jump to first page Introduction to Unix n Unix was born in 1969 at Bell Laboratories, a research subdivision.
Advertisements

Working with Files How to create, view, copy, rename and print files.
Cosc 4750 Getting Started in UNIX Don’t be afraid of the prompt, in linux it can be your best friend. In some cases, the only way to do certain things.
ATS Programming Short Course I INTRODUCTORY CONCEPTS Tuesday, Jan. 27 th, 2009 Essential Unix Commands.
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.
UNIX Utilities Software Tools. Slide 2 Getting Started on UNIX The machines in CS Lab2 are named csl2wk01 through csl2wk41. csl2wk01 means “CSLab2, workstation#1”
UNIX Chapter 00 A “ Quick Start ” into UNIX Operating System Mr. Mohammad Smirat.
Lecture 01CS311 – Operating Systems 1 1 CS311 – Lecture 01 Outline Course introduction Setting up your system Logging onto the servers at OSU with ssh.
Grep, comm, and uniq. The grep Command The grep command allows a user to search for specific text inside a file. The grep command will find all occurrences.
UNIX Utilities Learning Objectives: 1. To understand the some basic utilities of UNIX File 2. To compare UNIX shell and popular shell 3. To learn Input/Output.
CSCI 330 T HE UNIX S YSTEM File operations. OPERATIONS ON REGULAR FILES 2 CSCI The UNIX System Create Edit Display Contents Display Contents Print.
UNIX Filters.
7/17/2009 rwjBROOKDALE COMMUNITY COLLEGE1 Unix Comp-145 C HAPTER 2.
Linux Commands LINUX COMMANDS.
L INUX C OMMAND L INE I NTERFACE G UNAANBAN.G
CS 141 Labs are mandatory. Attendance will be taken in each lab. Make account on moodle. Projects will be submitted via moodle.
Chapter 4: UNIX File Processing Input and Output.
BILKENT UNIVERSITY DEPARTMENT OF COMPUTER TECHNOLOGY AND INFORMATION SYSTEMS CTIS156 INFORMATION TECHNOLOGIES II CHAPTER 10: ADVANCED FILE PROCESSING.
COMP1070/2002/lec4/H.Melikian COMP1070 Lecture #5  Files and directories in UNIX  Various types of files  File attributes  Notion of pathname  Commands.
Advanced File Processing
1 THE UNIX FILE SYSTEM By Chokechai Chuensukanant ID COSC 513 Operating System.
Unix Primer. Unix Shell The shell is a command programming language that provides an interface to the UNIX operating system. The shell is a “regular”
Working with Files Chapter 5. Display a Calendar Display a calendar for a specific month – cal Display a calendar for a specific year – cal 2000.
Lesson 11-Locating, Printing, and Archiving User Files.
Chapter 3: Command Line Utilities Doin’ stuff. In this chapter … Special characters Redirection More utilities than you shake a stick at.
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
Unix Basics Chapter 4.
BIF703 stdin, stdout, stderr Redirection. stdin, stdout, stderr Recall the Unix philosophy “do one thing well”. Unix has over one thousand commands (utilities)
– Introduction to the Shell 10/1/2015 Introduction to the Shell – Session Introduction to the Shell – Session 2 · Permissions · Users.
Title Slide CSS 404/504 The UNIX Operating System (2) By Ralph B. Bisland, Jr.
LIN Unix Lecture 3 Hana Filip. LIN UNIX Resources UNIX Tutorials UNIX help for.
Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working.
Jozef Goetz, expanded by Jozef Goetz, 2009 Credits: Parts of the slides are based on slides created by UNIX textbook authors, Syed M. Sarwar, Robert.
The Shell Chapter 7. Overview The Command Line Standard IO Redirection Pipes Running a Program in the Background Killing (a process!)
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.
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.
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 10 Linux.
Agenda Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Review next lab assignments Break Out Problems.
BIF713 Additional Utilities. Linux Utilities  You have learned many Linux commands. Here are some more that you can use:  Data Manipulation (Reg Exps)
Lesson 2-Touring Essential Programs. Overview Development of UNIX and Linux. Commands to execute utilities. Communicating instructions to the shell. Navigating.
Linux file system "On a UNIX system, everything is a file; if something is not a file, it is a process." Sorts of files (on a Linux system) Directories:
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX Commands cal – will print a calendar.
November 5, 2015CIS 118 Intro to UNIX What’s a Unix? Unix is an Operating System Designed for high-traffic usage Many variants –Linux, BSD: free versions.
1 © 2001 John Urrutia. All rights reserved. Chapter 3 An Introduction to the Utilities.
Chapter Five Advanced File Processing. 2 Lesson A Selecting, Manipulating, and Formatting Information.
Chapter Four I/O Redirection1 System Programming Shell Operators.
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands: whereis, which, whoami, finger, passwd, cal, date Working with Files: cat, more, less.
ULI101 More Linux Commands Introduction to UNIX/Linux and the Internet
Basic of UNIX For fresh members of SPARCS
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands: which, passwd, date, ps / kill Working with Files: file, touch, cat, more, less, grep,
ATS Programming Short Course I INTRODUCTORY CONCEPTS Tuesday, Feb 3 rd, 2009 Essential Unix Commands …the second half.
1 Introduction to Unix. 2 What is UNIX?  UNIX is an Operating System (OS).  An operating system is a control program that helps the user communicate.
A Brief Overview of Unix Brandon Bohrer. Topics What is Unix? – Quick introduction Documentation – Where to get it, how to use it Text Editors – Know.
CSCI 330 UNIX and Network Programming Unit II Basic UNIX Usage: File System.
Learning basic Unix command It 325 operating system.
CIT 140: Introduction to ITSlide #1 CSC 140: Introduction to IT File Processing.
Lesson 6-Using Utilities to Accomplish Complex Tasks.
Agenda The Bourne Shell – Part I Redirection ( >, >>,
File Management commands cat Cat command cat cal.txt cat command displays the contents of a file here cal.txt on screen (or standard out).
Linux Tutorial Lesson Two *Getting Help in Linux *Data movement and manipulation *Relative and Absolute path *Processes Note: see chapter 1,2,3 from Linux.
Linux Commands Help HANDS ON TRAINING Author: Muhammad Laique
Some Linux Commands.
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands:
Shell Script Assignment 1.
Basic UNIX OLC Training.
Guide To UNIX Using Linux Third Edition
Linux Shell Script Programming
Presentation transcript:

BIF703 Miscellaneous Commands

File related commands  grep - print lines matching a pattern  head - output the first part of files  tail - output the last part of files  sort - sort lines of text files  diff - find differences between two files  file - determine file type

Utility commands  who – show who is logged in  date – print or set the system date and time  which – show the full path of (shell) commands  finger – user information lookup program  mail – send and receive mail

Print commands  lpr – print files  lpq – show print queue status  lprm – cancel print jobs

grep  grep takes a pattern, read standard input or a list of files, and outputs the lines containing matches for the pattern. Example: grep foo * Print lines in any of the files in the current directory that contain the pattern “foo”.

grep options Major options for grep: -l display name of the file that has matching line -r search all the files in the current directory and all its subdirectory for the given pattern -n prefix each output with line number -w search for matching word -v output lines that do not contain the given pattern

grep examples  grep -r foo. Print all the lines in all the files in the current directory and all its subdirectories that contains the pattern “foo”.  grep -lr foo. Similar as above but only print the names of the files that contains the pattern “foo”

grep examples Print all the lines in the file “bar” that contains the pattern “foo” misc]$ grep foo bar This line contains the word foo and bar. Do you like to play football or basket ball? Same as above but prefix each line of output with the line number within the file “bar” misc]$ grep -n foo bar 3:This line contains the word foo and bar. 4:Do you like to play football or basket ball?

grep examples Print all the lines in the file “bar” that contains the word “foo” misc]$ grep -w foo bar This line contains the word foo and bar. Print all the lines in the file “bar” that does not contain the pattern “foo” misc]$ grep -v foo bar The name of this file is called bar. This file has only five line. This is the end of the file.

head & tail head bar Display the first 10 line of the file “bar” head -5 bar Display the first 5 lines of the file “bar” tail bar Display the last 10 lines of the file “bar” tail -5 bar Display the last 5 lines of the file “bar”

sort Sort line of text file cat numbers [root] sort numbers [root] sort -n numbers Numeric order String order

sort examples cat numbers sort numbers sort -k2 numbers Sort by the 1st field Sort by the 2 nd field

sort examples cat numbers sort numbers sort -r numbers Sort in revers e order

diff Display the differences between two files Syntax:  diff [options] file1 file2  When using “diff” without any options, it produces a series of lines containing: Add (a) Delete (d), and Change (c) instructions Each of these lines is followed by the lines from the file that you need to add, delete, or change to make the files the same.

diff examples cat file1 blue red white yellow orange cat file2 blue yellow black red orange $diff file1 file2 2,3d1 < red < white 4a3,4 > black > red 1. Delete line 2 through 3 from file1 2. Append lines 3 through 4 from file2 after line 4 in file1 Steps to convert file1 to file2:

file Displays the classification (type) of a file. Considered useful if a file extension is missing, or if user is unsure of file extension.  Syntax: file [option] file-list Examples: file assign01.html assign01.html: HTML document text file a.out a.out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), not stripped file mydoc.doc mydoc.doc: Microsoft Office Document file 1 1: empty

who Shows which users are logged on to server Phobos: /home/rchan>$ who rchan pts/0 Oct 30 02:08 (toronto-hse-ppp3) sslui pts/1 Oct 30 01:11 (CPE00112f0fe590-) Phobos: /home/rchan>$ who -H Name Line Time Hostname rchan pts/0 Oct 30 02:08 (toronto-hse-ppp3) sslui pts/1 Oct 30 01:11 (CPE00112f0fe590-) Phobos: /home/rchan>$ who -qH Name Hostname rchan (toronto-hse-ppp3) sslui (CPE00112f0fe590-) Total users: 2

who options Major options for grep: -H displays column headings -T includes message reception status: + message reception on - message reception off -i includes column indicating number of minutes of user inactivity.

who examples Show who is logged on who -H Name Line Time Hostname root pts/0 Mar 02 09:11 ( ) msaul pts/1 Mar 02 09:21 (CPE0040f4df2fef-) who -i root pts/0 Mar 02 09:11 0: ( ) msaul pts/1 Mar 02 09: who -T root - pts/0 Mar 02 09:11 msaul + pts/1 Mar 02 09:21 Less than 1 minute inactivity Allows message reception Column headings

date Displays the system time and date week8]$ date Sun Oct 30 01:48:10 EST 2005 week8]$ date +"%D" 10/30/05 week8]$ date +"%T" 01:54:05 week8]$ date +"%D %T" 10/30/05 01:54:13  Refer to the man page for more formatting codes

which Shows the full path of (shell) commands week8]$ which mkdir /bin/mkdir week8]$ which type /usr/bin/which: no type in (/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/ray/bin)

finger User information lookup program Phobos: /home/rchan>$ finger rchan Login name: rchan In real life: Raymond Chan Directory: /home/rchan Shell: /usr/bin/ksh On since Oct 30 02:08:55 on pts/0 from toronto-hse-ppp3 (messages off) No Plan.

mail Send and receive mail To read your mail on phobos, type the “mail” command by itself: Phobos: /home/rchan>$ mail Mail [5.2 UCB] [AIX 4.1] Type ? for help. "/var/spool/mail/rchan": 1 message 1 new >N 1 rchan Wed Oct 26 00:24 10/340 "Mail testing"

Sending mail To send a file called “letter” through on phobos to the user “rchan”: Phobos: /home/rchan>$ mail -s “subject” rchan < letter

lpr, lpq, lprm  lpr – submit file for printing lpr [ -P printer-name ] [ -# copies ] file-name [ -P printer-name] : send files to the named printer [ -# copies ] :sets the number of copies to print between 1 and 100 file-name : name of file to be printed

printer queue status  lpq - show printer queue status lpq [ -P printer-name] [ -a ] [ -l] [ -P printer-name] : show status on the named printer [ -a ] : reports jobs on all printers [ -l ] : display more verbose (long) format

Cancel Print Jobs  lprm – cancel print jobs lprm [ - ] [ -P printer-name] [ job ID(s)] [ - ] : all print jobs [ -P printer-name] : print jobs on the named printer [ job ID(s) ]: jobs to be cancel

Additional Resources Here are some Related-Links for Interest Only:  Linux manual pages (online):