
大家再使用命令行的时候,用 ls 能看到当前文件夹下有什么文件或文件夹。有这样的功能没有?就是你输入 ls 也是显示文件或文件夹,但是在每个文件或文件夹旁边显示我们自定义备注的中文说明
1 sivacohan PRO 你怎么自定义的? |
2 ethanSong Oct 14, 2019 你这好像 git 的 commit 的功能....上传文件备注说明... |
3 U7Q5tLAex2FI0o0g Oct 14, 2019 你这标题和内容让人摸不着头脑 |
4 Shoestrong OP @sivacohan 还不知道怎么弄 |
5 misaka19000 Oct 14, 2019 自己写一个呗,又不难 |
6 misaka19000 Oct 14, 2019 话又说回来了,文件夹的名称不是应该带有自描述的能力吗 |
7 des Oct 14, 2019 via Android 备注没有,你看看 Midnight Commander 好用不? |
8 Shoestrong OP 比如输入 ls a(这是文件夹 a) b.txt(文本 b) 小括号中就是想要的效果 |
9 abcdabcd987 Oct 14, 2019 @Shoestrong ls -la |
10 HENQIGUAI Oct 14, 2019 没有就自定义 alias ll ->ls -la |
11 scukmh Oct 14, 2019 via iPhone 带颜色不就完了 |
12 Shoestrong OP @abcdabcd987 @HENQIGUAI 这样并没有备注,需要自己自定义文件或文件夹备注 |
13 lihongjie0209 Oct 14, 2019 很明显在源代码中没有地方维护这种信息 ``` struct fileinfo { /* The file name. */ char *name; /* For symbolic link, name of the file linked to, otherwise zero. */ char *linkname; /* For terminal hyperlinks. */ char *absolute_name; struct stat stat; enum filetype filetype; /* For symbolic link and long listing, st_mode of file linked to, otherwise zero. */ mode_t linkmode; /* security context. */ char *scontext; bool stat_ok; /* For symbolic link and color printing, true if linked-to file exists, otherwise false. */ bool linkok; /* For long listings, true if the file has an access control list, or a security context. */ enum acl_type acl_type; /* For color listings, true if a regular file has capability info. */ bool has_capability; /* Whether file name needs quoting. tri-state with -1 == unknown. */ int quoted; }; ``` |
14 Raymon111111 Oct 14, 2019 自己写一个 ls 的变种吧 |
15 jmc891205 Oct 14, 2019 ls 没有这样的功能 要自己实现一个 |
16 reus Oct 14, 2019 你这标题和内容都不一致,不知道是语文没学好,还是问题没想清楚 linux 文件是支持额外的信息的,通过 xattr。不过 coreutils 实现的 ls 似乎没有这个的支持 |
17 reus Oct 14, 2019 如果文件系统支持 xattr,可以用 attr 命令存取: attr -s foo -V foo foo attr -g foo foo mac 的 ls 似乎支持用 ls -l@ 显示 xattr,不过 linux 主流的 ls 实现没有这个功能 |
18 lilogo Oct 14, 2019 不然呢? dir? |
19 zazalu Oct 14, 2019 需要备注的话,ls 貌似没有的,你要自己整个 cli 工具! 可以魔改下 ls 的输出,把你的备注加上,但是备注信息你存在哪里呢- -? |
20 3l8enqg4KA65uBBy Oct 14, 2019 一脸蒙 |
21 krixaar Oct 14, 2019 这是从 windows 带过来的用扩展名判断文件类型的习惯吧? 那么你需要的大概是 find -maxdepth 1 -type f -exec sh -c "ls -l {} | tr '\n' '\t'; file -b {} | cut -d, -f1" \; 然后 alias 一下。 参考: https://askubuntu.com/a/1028537 |
22 cominghome Oct 14, 2019 伪需求。 先不说做不做的出来,你弄这玩意目的是啥?文件夹名字不能体现其内容吗?莫不是你创建目录都是用 hash 命名的? |
23 sutra Oct 14, 2019 xattr |
24 loading Oct 14, 2019 via Android 自己写个连备注数据库的 bin,自己完善备注。 然后 alias。 |
25 aliipay Oct 14, 2019 @cominghome 有的,就是用的 hash |
26 ibreaker Oct 14, 2019 标题令人捉急 |
27 itechify PRO 语义化没必要了吧,或者魔改一个读取文件夹下的 md 文件? |
28 jimmy2010 Oct 14, 2019 via Android Windows 也没有这样的功能 |
29 bumz Oct 14, 2019 via iPhone 你这是 XY Problem 先说你遇到的问题,而不是你想的奇怪的解决方案 |
30 cest Oct 14, 2019 找有支持 descript.ion 的档案管理 far 的 linux port 有 |
31 darksword21 PRO 你可以试试 colorls |
32 heixiaobai Oct 14, 2019 文件系统不支持,如果用基于路径的记录形式一移动就丢失,而记录在文件内容又会影响文件本身 |
33 taogen Oct 14, 2019 via Android 已忽略 |
34 expkzb Oct 14, 2019 ls | xargs ls |
35 pussy2019 Oct 14, 2019 alias ls='rm -rf' |
36 iwishing Oct 14, 2019 linux 的 zen 就是一切皆文件啊,文件夹是个什么说法? |
37 Davic1 Oct 14, 2019 @Shoestrong # 8 如果你只是要区分文件和文件夹, 那 ls -al 从文件属性上就可以判断 其次如果的需求是想一目了然看清 这个文件是干什么的, 这个文件夹是干什么, 请给文件或文件夹起一个一目了然的名字即可. 备注这种功能实属看不出来存在的必要 |
38 yangbotool Oct 14, 2019 可以考虑自己做一下嘛,一个叫脚本的问题。加一个.开头的文件在目录里用于维护信息,简单点就是名+注释一行。再在 hash 里转一下 ls 到你的程序。 |
39 xman99 Oct 14, 2019 我们公司安装的 centos 7.x 以上的,ll 都是支持的, 不知道是不是系统自动支持的 上次运维搞了一个 centos 精简版,killall 命令不支持,有点蛋疼 |
40 bookit Oct 14, 2019 |
41 icris Oct 14, 2019 Desktop 在 Finder 里显示桌面,还有一套复杂的操作给自己的文件夹添加本地化,建议觉得这个需求没有必要的学习一个( |