Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Working with Files How to create, view, copy, rename and print files."— Presentation transcript:

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

2 Create a Calendar zCreate a calendar for a specific month ycal 12 2000 zCreate a calendar for a specific year ycal 2000

3 Creating a file with redirection zMost commands send their output to the screen. zYou can change (redirect) where you want the results sent. ycal 2000 > 2001

4 ls zlist zDisplays the names of the files in the current directory. zFlags: y-a: shows all the files, including hidden ones y-F: puts a / after directories, an * after executables, and an @ after links y-l: displays a long listing of files y-R: will also list contents of sub-directories y-s: will list the size of the files

5 Viewing the file zWhat if you want to see the contents of a file? zUse the cat command ycat [name of file] ycat 2000 zUse the more command ymore [name of file] ymore 2000

6 Chaining files together zUse the cat command to see more than one file ycal 6 2000 > june ycal 7 2000 > july ycal 8 2000 > august ycat june july august zSend the results to another file ycat june july august > summer2000

7 Appending files zUnix allows you to add information to the end of a file rather than overwriting it. zThis is called appending and is done with the >> ycal 9 2000 >> summer2000

8 cp zcopy zCopies the contents of one file to another. ycp [file to copy] [new file name] zFlags y-r: will copy directories and all their contents. yWithout this flag, the directory will not be copied and you will get an error message.

9 mv zmove zBetter name could be the rename command. zChanges the name of one file to another. ymv [old file name] [new file name] zNote, if [new file name] is a directory, you will move [old file name] to that directory and keep the original name.

10 lpr zprint command (stands for “line printer”) zThis prints the file(s) you specify to the printer you specify. ylpr [flags] [file name(s) to print] zFlags: y-P: specifies the name of the printer to print to. y-w[1-n]: specifies the number of pages to print per page. y-h: removes the header page.

11 lpq zview print queue (stands for “line printer query”) zWhen you print a file, it gets sent to a print queue (a line of files waiting to be printed). zlpq will show you the names of the files in the print queue. zUse the -P flag just like in lpr to specify the printer whose queue you wish to view.

12 lprm zline printer remove zUsed to remove a file from the print queue. zUse the lpq to see the file and then use lprm [job number] to remove the specific job. zYou can only remove print jobs that you sent to the printer. zUse the ‘-’ flag to remove all your files.

13 rm zremove zDeletes the specified file or files. zThis is destructive! zThey are gone! zThey cannot be retrieved!!! yrm [file name] zNote: this does not generally work with directories.

14 Working with Directories A directory is just a file that contains other files. Now we will learn commands to create directories, move files between directories, rename files and delete directories.

15 mkdir zmake directory zThis creates a directory. ymkdir [new directory name] ymkdir calendar

16 Moving files between directories zWhen you create a directory, it contains no files. zYou need to put files into it with the mv command. ymv summer2000 calendar

17 zYou can create subdirectories within directories. ymkdir calendar/months zYou can move files into those subdirectories ymv june calendar/months zYou can use other commands in a similar manner yls calendar/months yls / Using pathnames

18 cd zchange directory zChanges the directory to whatever you specify. ycd [name of directory] zWithout any directory (just cd) you will be taken to your home directory.

19 pwd zprint working directory zDisplays the full path of the current directory you are in.

20 rmdir zremove directory zThis deletes a directory (as opposed to the rm command above). zThe directory must be empty otherwise you will get an error.

21 Reading zChapters 7 and 8 zAccess PrivilegesAccess Privileges


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

Similar presentations


Ads by Google