Working with Files How to create, view, copy, rename and print files.

Slides:



Advertisements
Similar presentations
Introduction to the Omega Server CSE Overview Intro to Omega Basic Unix Command Files Directories Printing C and C++ compilers GNU Debugger.
Advertisements

Linux Orientation Computer Systems Lab Computer Sciences Department Room 2350.
Learning Unix/Linux Bioinformatics Orientation 2008 Eric Bishop.
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
Lab6 CPCS361 I.Mona Alshehri. Working with Files and Directories Creating files Create a file with the cat command type the command cat > name_of_file.
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.
Linux+ Guide to Linux Certification, Second Edition
Linux Files. Files and directories As in Windows directories are structures which contain –Other directories –Files.
CIS 240 Introduction to UNIX Instructor: Sue Sampson.
UNIX Chapter 00 A “ Quick Start ” into UNIX Operating System Mr. Mohammad Smirat.
CS 497C – Introduction to UNIX Lecture 13: - The File System Chin-Chih Chang
9-2 How do you copy/move/rename/remove files? How do you create a directory ? What is redirection and piping? Readings: See CCSO’s Unix pages andCCSO’s.
1 Some basic Unix commands u Understand the concept of loggin into and out of a Unix shell u Interact with the system in a basic way through keyboard and.
A Mini UNIX Tutorial. What’s UNIX?  An operating system run on many servers/workstations  Invented by AT&T Bell Labs in late 60’s  Currently there.
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.
Learning basic Unix command IT 325 operating system.
"Two of the most famous products of Berkeley are LSD and Unix. I don't think that this is a coincidence.” Anonymous.
COMP1070/2002/lec4/H.Melikian COMP1070 Lecture #5  Files and directories in UNIX  Various types of files  File attributes  Notion of pathname  Commands.
1 THE UNIX FILE SYSTEM By Chokechai Chuensukanant ID COSC 513 Operating System.
Help session: Unix basics Keith 9/9/2011. Login in Unix lab  User name: ug0xx Password: ece321 (initial)  The password will not be displayed on the.
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 How to create, view, copy, rename and print files.
Lesson 7-Creating and Changing Directories. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files.
CHAPTER 1 UNIX FOR NONPROGRAMMERS By U ğ ur Halıcı.
Linux Directory Navigation. File & Directory Commands This is a minimal list of Unix commands that you must know for file management: ls (list) mkdir.
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.
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
1 Lecture 2 Working with Files and Directories COP 3344 Introduction to UNIX.
Lesson 11-Locating, Printing, and Archiving User Files.
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
Unix Basics Chapter 4.
®® Microsoft Windows 7 for Power Users Tutorial 13 Using the Command-Line Environment.
Linux+ Guide to Linux Certification, Second Edition
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 UNIX development environment CS 400/600 – Data Structures.
Lesson 2-Touring Essential Programs. Overview Development of UNIX and Linux. Commands to execute utilities. Communicating instructions to the shell. Navigating.
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX Commands cal – will print a calendar.
Introduction to Unix – CS 21 Lecture 4. Lecture Overview * cp, mv, and rm Looking into files The file command head and tail cat and more What we’ve seen.
BIF713 Basic Unix/Linux Commands Getting Help with Commands.
Introduction to UNIX Geraint Vaughan. What is UNIX? Command-line operating system (not point- and click) Designed for ‘experts’ Lots of different variants.
Welcome to CS323 Operating System lab 1 TA: Nouf Al-Harbi NoufNaief.net.
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands: whereis, which, whoami, finger, passwd, cal, date Working with Files: cat, more, less.
Linux+ Guide to Linux Certification, Third Edition
Linux+ Guide to Linux Certification, Third Edition
Introduction to Programming Using C An Introduction to Operating Systems.
Manipulating Files Refresher. The touch Command touch is used to create a new, empty file. If the file already exists, touch updates the time and date.
Linux - Ubuntu LECTURE TWO. Objective: Enable students to understand the practical side of Linux operating system. Understand and implement the following.
Linux Commands C151 Multi-User Operating Systems.
UNIX filesystem CS 2204 Class meeting 2 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
Basic Unix Commands. Listing files and directories ● ls:command is used to list the files and ● directories in present working directory ● ls command.
Learning basic Unix command It 325 operating system.
CIT 140: Introduction to ITSlide #1 CSC 140: Introduction to IT File Processing.
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.
CMSC 104, Version 8/061L03OperatingSystems.ppt Operating Systems and Using Linux Topics What is an Operating System? Linux Overview Frequently Used Linux.
Learning Unix/Linux Based on slides from: Eric Bishop.
UNIX To do work for the class, you will be using the Unix operating system. Once connected to the system, you will be presented with a login screen. Once.
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.
Andy Wang Object Oriented Programming in C++ COP 3330
Some Linux Commands.
C151 Multi-User Operating Systems
The Command Prompt Commands are the way to “do things” in Unix
Operating Systems and Using Linux
UNIX/LINUX Commands Using BASH Copyright © 2017 – Curt Hill.
Module 6 Working with Files and Directories
Lab 2: Terminal Basics.
January 26th, 2004 Class Meeting 2
Presentation transcript:

Working with Files How to create, view, copy, rename and print files.

clear clear - clear the terminal screen When working on the terminal use clear to get a fresh screen so you can work from the top. Example: grid: clear

File Extensions No set rules for assigning file extensions. However, some extensions allow their associated program to access them. – Ex..cc,.cpp are C++ programming extensions. – Ex..out,.exe are executable extensions. Unix allows files with no extensions. They are useful as a way of identifying the type of file. Ex..txt,.cpp,.dat,.bac

Create a file - touch touch - change file timestamps ‘create’ Can create a file basic empty file using the ‘touch’ command. touch [file to be created] Example: grid: touch file1.txt This creates an empty file named file1.txt. If file exists it will NOT overwrite it.

Create a file - cat cat - concatenate and display file(s). Can be used to create or read a file. Also can be used to append or copy a file to an existing file. Or can be used to re-direct output from a program to a file. Viewing the contents of a file Usage: cat [file to view] – Example: grid: cat file1.txt

more A second command to view file contents is more Usage: more [file to view] – Example: grid: more note cat will display the entire file. more allows you to scroll through the file a few of lines at a time. Use spacebar to page forward Use enter key to move forward line by line

cat and the ‘>’ operator (Writing to a file) Use with the redirection operator ‘>’ to create a file with text inside. If file does not exist, it will create it. If one already exists, it will overwrite it! After executing command, prompt will go to next line where you can begin typing your note. After note, hit return, then control-c to close the file. – Example: grid: cat > note – Just a quick note or reminder –

cat and the ‘>>’ operator (Appending two files) You can add the contents of one file onto the back of another file using the appending operator ‘>>’ with the cat command. Usage: cat [source file] >> [target File] – Example: grid: cat note >> note2 Executing this command would result in the contents of note being appended to note2. Alternatively: – Example: grid: cat >> note2 – Then type text to be appended

cat (Copying contents of file) Works with the redirection operator Redirecting the contents of one file into another file. Assumes the source file exists. Good way of making a backup of a file. Usage: cat [source file] > [target file] – Ex. Cat temp1 > temp1.backup

cp copy - copy files and directories Copies the contents of one file to another. – cp [file to copy] [new file name] – If file to copy is not local, then you must supply the pathname. Example: grid: cp /home/CS/cs140/Hwk/file.txt. The period at the end is necessary if you do not specify a new filename for the copied file. Otherwise, provide a new file name – Flags: The two most common flags for copying entire directories (and subdirectories) -r - copy recursively, non-directories as files -R - copy directories recursively

cp EXAMPLES……. – Copying a file using an absolute path cp [absolute path of file TO BE COPIED] grid: cp /home/CS/cs140/001/test.txt mytest.txt – Copying a file using a relative path cp [relative path of file TO BE COPIED] grid: cp../Test/final.txt exams/myfinal.txt The period is necessary if you do not supply a filename or path for the copied file (refers to the working directory). grid: cp../Test/final.txt.

mv mv - move (or rename) files Takes existing filename and renames it to a new filename. – mv [old file name] [new file name] – Example: grid: mv test1.txt final.txt Works with directories as well – Mv [old directory name] [new directory name] – Example: grid: mv TEST TEST2 Moves files – Mv [file name] [new path and name] – Example: grid: mv lab1.txt labs/lab1.txt

rm rm - remove files or directories Deletes the specified file or files. Remember, once a file/directory is removed, it is not recoverable! – rm [file name] – Example: grid: rm test.txt Note: this does not generally work with directories. Use rmdir for directories.

lpr (print command) lpr - submit print requests (miller man listing) This prints the file(s) you specify to the printer you specify. – lpr [flags] [file name to print] We will need to use the –P flag when printing. – -P: specifies the destination of the printer to print to. A destination will be a room number which has a printer that is on the particular system. Example: grid: lpr –Pe270 File.txt

lpq lpq - display the content of a print queue If you made a print request (lpr) and nothing is happening, check the print queue to make sure the printer received it. lpq –P[printer destination] – Example: grid: lpq –Pe270

lprm lprm - remove print requests from the print queue If you made several print requests and wish to cancel them use lprm with your login name to delete the print jobs from the queue lprm –P[printer destination] [user id] – Example: grid: lprm –Pe270 car.txt

Misc. ! [Letter] – repeats the last command used that began with that letter. – Example: miller: clear miller: !c * is a wildcard character – Example: miller: ls web* – Example: miller: rm * THIS COMMAND WILL REMOVE ALL FILES IN THE WORKING DIRECTORY. – BE CAREFUL! | is called the pipe. It will connect the output of one command to the input of another. – Example: miller: ls –l /users/st/ugrad | more