Книга: Fedora™ Unleashed, 2008 edition

Managing Files with the Shell

Managing Files with the Shell

Managing files in your home directory involves using one or more easily remembered commands. If you have any familiarity with the now-ancient DOS, you recognize some of these commands (although their names differ from those you remember). Basic file management operations include paging (reading), moving, renaming, copying, searching, and deleting files and directories. These commands include the following:

cat filename — Outputs contents of filename to display

less filename — Allows scrolling while reading contents of filename

mv file1 file2 — Renames file1 to file2

mv file dir — Moves file to specified directory

cp file1 file2 — Copies file1 and creates file2

rm file — Deletes file

rmdir dir — Deletes directory (if empty)

grep string file(s) — Searches through files(s) and displays lines containing matching string

Note that each of these commands can be used with pattern-matching strings known as wildcards or expressions. For example, to delete all files in the current directory beginning with the letters abc, you can use an expression beginning with the first three letters of the desired filenames. An asterisk (*) is then appended to match all these files. Use a command line with the rm command like this:

$ rm abc*

Linux shells recognize many types of filenaming wildcards, but this is different from the capabilities of Linux commands supporting the use of more complex expressions. You learn more about using wildcards in Chapter 11, "Automating Tasks."

NOTE

Learn more about using expressions by reading the ex or grep manual pages.

Оглавление книги


Генерация: 0.036. Запросов К БД/Cache: 0 / 0
поделиться
Вверх Вниз