Linux Server Configuration


Display A Text File One Screen At A Time: less, more


Download 493.5 Kb.
bet6/48
Sana16.06.2023
Hajmi493.5 Kb.
#1495871
1   2   3   4   5   6   7   8   9   ...   48
Bog'liq
0501-linux-server-configuration

1.4.3 Display A Text File One Screen At A Time: less, more


When you want to view a file that is longer than one screen, you can use either the less utility or the more utility. Each of these utilities pauses after displaying a screen of text. Because these utilities show one page at a time, they are called pagers. Although less and more are very similar, they have subtle differences. At the end of the file, for example, less displays an EOF (end of file) message and waits for you to press q before returning you to the shell. In contrast, more returns you directly to the shell. In both utilities you can press h to display a Help screen that lists commands you can use while paging through a file. For example:


$ more target-file(s)


displays the contents of target-file(s)  on the screen, pausing at the end of each screenful and asking the user to press a key (useful for long files). It also incorporates a searching facility (press '/' and then type a phrase that you want to look for).

1.4.4 Copy A File: cp


The cp (copy) utility (Figure 1.6.1) makes a copy of a file. This utility can copy any file, including text and executable program (binary) files. You can use cp to make a backup copy of a file or a copy to experiment with. The cp command line uses the following syntax to specify source and destination files:




cp source-file destination-file

The source-file is the name of the file that cp will copy. The destination-file is the name that cp assigns to the resulting (new) copy of the file.


$ ls


memo
$ cp memo memo.copy
$ ls
memo memo.copy
The cp command line in Figure 1.6.1 copies the file named memo to memo.copy. The period is part of the filename—just another character. The initial ls command shows that memo is the only file in the directory. After the cp command, second ls shows two files in the directory, memo and memo.copy.



Download 493.5 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8   9   ...   48




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling