加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

vim – 打开vi中的所有文件(包括隐藏文件)

发布时间:2020-12-15 21:21:42 所属栏目:安全 来源:网络整理
导读:我有一个像这样的文件结构 /foo/bar/├── .foo.cfg├── foo.cfg├── foo.data├── foo.py├── .svn│?? ├── ...│?? ├── ...│?? └── ...├── .└── .. 我想打开所有隐藏和非隐藏文件到vim.我可以像这样手动完成 vi .foo.cfg foo.cfg
我有一个像这样的文件结构

/foo/bar/
├── .foo.cfg
├── foo.cfg
├── foo.data
├── foo.py
├── .svn
│?? ├── ...
│?? ├── ...
│?? └── ...
├── .
└── ..

我想打开所有隐藏和非隐藏文件到vim.我可以像这样手动完成

vi .foo.cfg foo.cfg foo.data foo.py

但是当有100个文件时,这不起作用.我也试过以下但没有成功

#hidden files not loaded
vi *

#Includes folders and '.' and '..'
vi * .*

#loads files one at a time
for i in `ls -a` ; do vi $i; done;

#loads files one at a time
find . -name "*" -type f -maxdepth 1 -exec vi {} ";"

解决方法

以下应该有效:

find . -maxdepth 1 -type f -exec vi {} +

从查找手册页:

06001

This variant of the -exec option runs the specified command on the selected files,but the command line is built by appending each selected file name at the end; the total number of invocations of the command will be much less than the number of matched files. The command line is built in much the same way that xargs builds its command lines. Only one instance of ’{}’ is allowed within the command. The command is executed in the starting directory.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读