Linux Lecture #02. File Related Commands cat --Concatenate and print (display) the content of files. --Also used to create a new file. Syntax cat [Options]

Slides:



Advertisements
Similar presentations
Learning Unix/Linux Bioinformatics Orientation 2008 Eric Bishop.
Advertisements

Manipulating files in UNIX. Common operations of files Common operations: We will learn to do these operations and more.... Create a file Print a file.
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.
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 Chapter 09 Basic File Processing Mr. Mohammad Smirat.
CS 497C – Introduction to UNIX Lecture 12: - The File System Chin-Chih Chang
Chapter 7 Advanced Directory and File Management.
CIS 240 Introduction to UNIX Instructor: Sue Sampson.
Guide To UNIX Using Linux Third Edition
T UTORIAL OF U NIX C OMMAND & SHELL SCRIPT S 5027 Professor: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2015.
Understanding the Basics of Computational Informatics Summer School, Hungary, Szeged Methos L. Müller.
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.
Lesson 7-Creating and Changing Directories. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files.
Chapter 9 Part II Linux Command Line Access to Linux Authenticated login using a Linux account is required to access a Linux system. The Linux prompt will.
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.
June 1, 1999Manipulating Files1 Introduction to UNIX E. Manipulating Files.
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.
Basic unix commands that everyone should know (Even if you have a mac) Slightly more advanced:
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.
Managing Files. Module 5 Managing Files ♦ Introduction “On a Linux system, everything is a file; if something is not a file, it is a process.” ♦ Topics.
BIF713 Basic Unix/Linux Commands Getting Help with Commands.
Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008 Chapter 8: The UNIX File System Continued 1 of 44 Copyright ©2008 by Pearson Education, Inc. Upper.
Basic MS-DOS. History MS-DOS 1.0 was released in August 1981, and was updated until April 1994 when it was replaced by Windows 95 All versions of windows.
Chapter 1 : The Linux System Part 2 Lecture 2 11/14/
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
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.
Λειτουργικά Συστήματα – Lab2 Γιάννης Πετράκης. Directory Navigation and Control  The Unix file system is set up like a tree branching out from the root.
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands: which, passwd, date, ps / kill Working with Files: file, touch, cat, more, less, grep,
Linux - Ubuntu LECTURE TWO. Objective: Enable students to understand the practical side of Linux operating system. Understand and implement the following.
EGEE-III INFSO-RI Enabling Grids for E-sciencE Apr. 25, Grid Computing Hands On Training for Users Faculty of Sciences, University.
PTA Linux Series Copyright Professional Training Academy, CSIS, University of Limerick, 2006 © Workshop III - Part B Shell Commands Professional Training.
Files and Directories in UNIX The first file in UNIX file system is “root” or “/”
Linux Stuff Last Update Copyright 2014 Kenneth M. Chipps Ph.D. 1.
Unix Fundamentals CS 127. File navigation cd - change directory cd /var/log cd /etc/apache2 cd ~/Desktop ~ is a shortcut for the home directory.
Basic Unix Commands. Listing files and directories ● ls:command is used to list the files and ● directories in present working directory ● ls command.
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.
Learning Unix/Linux Based on slides from: Eric Bishop.
1 Linux Commands. 2 Path You specify a file or directory by its path name:  the full, or absolute, path name or the one relative to a location. The full.
UNIX  Portable (common to many computer architectures), multitasking, multi-user operating system  Introduced by Bell labs in mid-1960’s  Thus, much.
Tutorial of Unix Command & shell scriptS 5027
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.
Linux Commands Workout 1
Some Linux Commands.
Useful Linux Commands.
INTRODUCTION TO UNIX: The Shell Command Interface
Tutorial of Unix Command & shell scriptS 5027
Tutorial of Unix Command & shell scriptS 5027
LING 408/508: Computational Techniques for Linguists
Operating Systems and Using Linux
Tutorial of Unix Command & shell scriptS 5027
The Unix File System.
Chapter Four UNIX File Processing.
UNIX/LINUX Commands Using BASH Copyright © 2017 – Curt Hill.
Tutorial Unix Command & Makefile CIS 5027
The Linux Command Line Chapter 4
Module 6 Working with Files and Directories
Lab 2: Terminal Basics.
The Linux Command Line Chapter 4
Presentation transcript:

Linux Lecture #02

File Related Commands cat --Concatenate and print (display) the content of files. --Also used to create a new file. Syntax cat [Options] [File]... Concatenate FILE(s), or standard input, to standard output. Examples: Display a file: $ cat myfile.txt Concatenate two files: $ cat File1.txt File2.txt > union.txt If you need to combine two files but also eliminate duplicates, this can be done with sort unique: $ sort -u File1.txt File2.txt > unique_union.txtsort Put the contents of a file into a variable $ my_variable=`cat File3.txt` create a new file $cat > filename …. ^Z to save & exit.

File Related Commands….. cp Copy one or more files to another location Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY. Syntax cp [options]... Source Dest Examples Copy demofile to demofile.bak : $ cp demofile demofile.bak or $ cp demofile{,.bak} Copy demofile.txt to demofile.bak : $ file="demofile.txt" $ cp $file ${file%.*}.bak Copy floppy to home directory: $ cp -f /mnt/floppy/* ~

File Related Commands…. mv Move or rename files or directories. SYNTAX mv [options]... Source Dest mv [options]... Source... Directory If the last argument names an existing directory, `mv' moves each other given file into a file with the same name in that directory. Otherwise, if only two files are given, it renames the first as the second. It is an error if the last argument is not a directory and more than two files are given. Examples Rename the file apple as orange.doc: mv apple orange.doc Move orange.doc to the Documents folder: mv orange.doc./Documents/orange.doc

File Related Commands….. rm Remove files (delete/unlink) Syntax rm [options]... file... Options -f, --force ignore nonexistent files, never prompt -i Prompt before every removal -r, -R, --recursive Remove directories and their contents recursively -v, --verbose Explain what is being done IMPORTANT: rm does not delete directories without –r option

Exercise Create the following tree structure: / gec cseece ABAB CDCD MNMN

Wild Card Characters Used for matching patterns: ?Matches with one non empty character *Mather with everything, including blank []Matches with a specific set of characters given in brackets. These characters can be used for multiple file selection in cp, mv or rm commands.

Wild Card Characters…… A folder contains the following files: A1, A2, A11, A22, B1, B2 To delete A1, A2, we can use: $ rm A? To delete A1, A2, A11, A22, we can use: $ rm A* To delete A1 and B1, we can use: $ rm ?1