Dired, the directory Editor

You can also view a list of files in a directory with C-x C-d (list-directory). Unlike Dired, this command does not allow you to operate on the listed files.

1. Entering Dired
To invoke Dired, type C-x d (dired). This reads a directory name using the minibuffer, and opens a Dired buffer listing the files in that directory.

You can also invoke Dired by going C-x C-f(find-file) a directory name.

The variable dired-listing-switches specify the options to give to ls for listing the directory; this string must contain '-l'.

To display the Dired buffer in another window rather than in the selected window, use C-x 4 d (dired-other-window) instead of C-x d. C-x 5 d (dired-other-frame) uses a separate frame to display the Dired buffer.

2. Navigation in the Dired buffers
All the usual Emacs cursor motion commands are available in Dired buffers.

For extra convenience, SPC and n in Dired are equivalent to C-n. p is equivalent to C-p. DEL (move up and unflag) is also often useful simply  for moving up. j (dired-goto-file) prompts for a file name using the minibuffer, and moves point to the line in the Dired buffer describing that file. M-s f C-s (dired-isearch-filename) performsa forward incremental search in the Dired buffer, looking for matchesonly amongst the file names and ignoring the rest of the next in thebuffer. M-s f M-C-s (dired-isearch-filename-regexp) does the same, using a regular expression search.

3. Deleting Files with Dired
d          Flag this file for deletion.(dired-flag-file-deletion)
         Remove deletion flag on this line. (dired-unmark)
DEL     Move point to previous line and remove the deletion flag on that line. (dired-unmark-backwark)
x          Delete the file that are flagged for deletion. (dired-do-flagged-delete)

Youcan delete empty directories just like other files, but normally Diredcannot delete directories that are nonempty. If the variable dired-recursive-deletes is non-nil, then Dired can delete nonempty directories including all their contents.

4. Flagging Many Files at once
The #, ~, ., % &, and % d commands flag many files for deletion, based on their file names:
#                               Flag all auto-save files(files whose names start andend with '#')for deletion.(dired-flag-auto-save-files)
~                                Flag all backup files(files whose names end with '~') for deletion.(dired-flag-backup-files)
.(Period)                  Flag excess numeric backup files for deletion. The oldest andnewest few backup files of any one file are exempt;
                                 the middle ones are flagged.(period, dired-clean-directory)
% &                          Flag for deletion all files with certain kinds of nameswhich suggest you could easily create those files again.
                                 (dired-flag-garbage-files)
% d regexp RET     Flag for deletion all files whose names match the regular expression regexp.(dired-flag-files-regexp)
                  
5. Visiting Files in Dired
Allof these commands apply to the current line's file; if that file isreally a directory, these commands invoke Dired on that subdirectory
(making a separate Dired buffer).

f
e  
RET
      Visit the file described on the current line, like typing C-x C-f and supplying that file name (dired-find-file).
         like f, but uses another window to display the file's buffer(dired-find-file-other-window). The Dired buffer remains visible
             in the first window. This is like using C-x 4 C-f to visit the file.
C-o       Visit the file described on the current line, and display the buffer in another window, but do not select that window
             (dired-display-file).
v          View the file described on the current line, using M-x view-file(dired-view-file). Viewing a file with view-file is like viewing it,
             but is slanted toward moving around in the file conveniently and does not allow changing the file.
^          Visit the parent directory of the current directory(dired-up-directory). This is equivalent to moving to the line for '..'and
             typing f there.
           
6. Shell Commands in Dired
The Dired command ! (dired-do-shell-command) reads a shell command string in the minibuffer and runs that shell command on one or more files. The command X is a synonym for !.

The command & (dired-do-async-shell-command)does the same, except that it runs the shell command asynchronously.You can also do this with !, by appending a '&' character to theend of the shell command.

7. Subdirectories in Dired
A Dired buffer displays just one directory in the normal case; but you can optionally include its subdirectories as well.

i               Insert the contents of a subdirectory later in the buffer.Ifthe subdirectory's contents are already present in the buffer,
                 the i command just moves to it.

               update the subdirectory's contents. (dired-do-redisplay)
C-u k        delete the subdirectory on the subdirectory header line.

8. Moving over subdirectories
C-M-n    Go to next subdirectory header line, regardless of level(dired-next-subdir)
C-M-p    Go to previous subdirectory header line, regardless of level (dired-prev-subdir).
C-M-u    Go up to the parent directory's header line(dired-tree-up).
C-M-d    Go down in the directory tree, to the first subdirectory's header line(dired-tree-down).
<             Move up to the previous directory-file line(dired-prev-dirline).
>             Move down to the next directory-file line (dired-prev-dirline).

9. Hiding subdirectories
      Hide or show the subdirectory that point is in, and move point tothe next subdirectory (dired-hide-subdir). This is a toggle.
          A numeric argument serves as a repeat count.
M-$   Hide all subdirectories in this Dired buffer, leaving only their headerlines (dired-hide-all). Or, if any subdirectory is currently hidden,
          make all subdirectories visible again.
       
10. Updating the Dired buffer
g      Update the entire contents of the Dired buffer(revert-buffer).
     Update the specified files (dired-do-redisplay). If you use l on asubdirectory header line, it updates the contents of the
        corresponding subdirectory.
k      Delete the specified file lines---not the files, just the lines (dired-do-kill-lines).
s      Toggle between alphabetical order and date/time order (dired-sort-toggle-edit).
C-u s switches RET
        Refresh the Dired buffer using switches as dired-listing-switches.

11. Viewing Image Thumbnails in Dired
Image-Diredis a facility for browsing image files. To enter Image-Dired, mark theimage files you want to look at in the Dired buffer, using m as usual.Then type C-t d (image-dired-display-thumbs).This creates and switches to a buffer containing image-dired, corresponding
to the marked files.

You can also enter Image-Dired directly by typing M-x image-dired.

Toview and the image in its original size, either provide a prefixargument (C-u) before pressing RET, or type C-RET(image-dired-thumbnail-display-external) to display the image in anexternal viewer. You must first configure image-dired-external-viewer.

You can delete images through Image-Dired also. Type d (image-dired-flag-thumb-original-file)to flag the image file for deletion in the Dired buffer. You can alsodelete the thumbnail image from the thumbnail buffer with C-d (image-dired-delete-char).

In the thumbnail buffer, type L to rotate the original image 90 degrees anti clockwise, and R to rotate it 90 degrees clockwise.

12. other Dired Features
The command + (dired-create-directory) reads a directory name, and creates the directory if it does not already exist.

13. Operating on Files
All of these commands let you specify the files to manipulate in these ways:

Ifyou give the command a numeric prefix argument n, it operates on thenext n files, starting with the current file. (If n is negative, the
command operates on the -n files preceding the current line.)

Otherwise, if some files are marked with '*', the command operates on all those files.

Otherwise, the command operates on the current file only.

All of these commands is omited. But you may refer to the  GNU Emacs Manual.

NOTE: This article comes from GNU Emacs Manual.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
提供的源码资源涵盖了小程序应用等多个领域,每个领域都包含了丰富的实例和项目。这些源码都是基于各自平台的最新技术和标准编写,确保了在对应环境下能够无缝运行。同时,源码中配备了详细的注释和文档,帮助用户快速理解代码结构和实现逻辑。 适用人群: 适合毕业设计、课程设计作业。这些源码资源特别适合大学生群体。无论你是计算机相关专业的学生,还是对其他领域编程感兴趣的学生,这些资源都能为你提供宝贵的学习和实践机会。通过学习和运行这些源码,你可以掌握各平台开发的基础知识,提升编程能力和项目实战经验。 使用场景及目标: 在学习阶段,你可以利用这些源码资源进行课程实践、课外项目或毕业设计。通过分析和运行源码,你将深入了解各平台开发的技术细节和最佳实践,逐步培养起自己的项目开发和问题解决能力。此外,在求职或创业过程中,具备跨平台开发能力的大学生将更具竞争力。 其他说明: 为了确保源码资源的可运行性和易用性,特别注意了以下几点:首先,每份源码都提供了详细的运行环境和依赖说明,确保用户能够轻松搭建起开发环境;其次,源码中的注释和文档都非常完善,方便用户快速上手和理解代码;最后,我会定期更新这些源码资源,以适应各平台技术的最新发展和市场需求。 所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答!
好的,我会逐个回答您的问题。 1. 新建目录/test_AAA_YY/work7-2/,在该目录下新建文件AAA_01,将ls命令的帮助文件(ls --help)写入文件AAA_01。 ``` mkdir -p /test_AAA_YY/work7-2/ touch /test_AAA_YY/work7-2/AAA_01 ls --help > /test_AAA_YY/work7-2/AAA_01 ``` 2. 使用管道符查询ls命令帮助文档中单词Display的出现情况。 ``` ls --help | grep -w "Display" ``` 执行结果如下: ``` --dired generate output designed for Emacs' dired mode -l use a long listing format -q, --hide-control-chars print ? instead of non graphic characters -Q, --quote-name enclose entry names in double quotes --show-control-chars show non graphic characters as-is (default unless program is 'ls' and output is a terminal) -s, --size print the allocated size of each file, in blocks -t sort by modification time, newest first --time with -l, show time as modification time --time-style=TIME_STYLE time/date format with -l; see TIME_STYLE below --color[=WHEN] colorize the output; WHEN can be 'always' (default if omitted), 'auto', or 'never'; more info below --group-directories-first group directories before files; -h, --human-readable with -l and/or -s, print human readable sizes (e.g., 1K 234M 2G) --si likewise, but use powers of 1000 not 1024 ``` 3. 设置组合命令,要求从/etc/sysconfig/network-script/ifcfg-ens33文件中查找到所设置的IP地址,并将结果写入到/test_AAA_YY/AAA_02文件中;(一条命令) ``` grep "IPADDR" /etc/sysconfig/network-scripts/ifcfg-ens33 > /test_AAA_YY/AAA_02 ``` 4. 使用echo命令输出字符串teacher’s books。 ``` echo 'teacher’s books' ``` 执行结果如下: ``` teacher’s books ``` 5. 定义变量AAA_YY,使用echo输出变量AAA_YY的值时,显示的内容为:create one random number is ****。 ``` AAA_YY="create one random number is ****" echo $AAA_YY ``` 执行结果如下: ``` create one random number is **** ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值