2 面板文件管理器用户的命令行智慧
想要通过用命令行(bash 或 cygwin)替换 2 面板文件管理器来升级我的文件管理效率。命令行可以给出相同的速度吗?请教大师如何做,例如将目录A中的某些文件复制到目录B。是否大量使用pushd/popd?或者创建最常用目录的链接?管理命令行主文件的最佳实践和日常例程是什么?
Want to upgrade my file management productivity by replacing 2 panel file manager with command line (bash or cygwin). Can commandline give same speed? Please advise a guru way of how to do e.g. copy of some file in directory A to the directory B. Is it heavy use of pushd/popd? Or creation of links to most often used directories? What are the best practices and a day-to-day routine to manage files of a command line master?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的经验是,命令行复制速度明显更快(尤其是在 Windows 环境中)。当然,基本物理定律仍然适用,比 1 秒复制的文件大 1000 倍的文件仍然需要 1000 秒才能复制。
因为我经常有 5-10 个使用类似目录结构的项目,所以我使用命名约定为每个子目录设置变量:
你可以做这样的事情根据需要选择斯巴达式或巴洛克式,以符合您的生活/编程理论。
然后您可以轻松地将 cfg 从 1 个项目复制到另一个项目
cp -p $NM_cfg/*.cfg ${altM_cfg}
有些人似乎真的很喜欢这样。你可以尝试一下,看看你喜欢什么。
根据我的经验,指向目录的链接更多地用于软件开发,其中源代码需要一组特定的目录名称,而您的安装有不同的名称。然后建立链接来提供预期的目录路径是有帮助的。对于生产数据来说,这只是另一件可能会变得混乱或崩溃的事情。这并不总是正确的,也许你有一个非常好的理由来建立链接,但我不会这样开始,只是因为这是可能的。
(根据上面的内容,对所有项目使用标准化目录结构。
让脚本将任何小文件保存到您的部门在 /tmp 目录中保存的目录中。
即 /tmp/MyDeptsTmpFile (命名以适合您当地的约定))
这取决于。如果您谈论的是数据和日志文件,带日期的文件名可以节省您大量时间。如果您需要额外的分辨率,我推荐像 YYYYMMDD(_HHMMSS) 这样的 dateFmts。
带日期的日志文件非常方便,当当前进程似乎花费了很长时间时,您可以查看一周前的日志文件并准确量化该进程花费了多长时间,一周,一个月,6个月(最多多少时间)您可以负担得起的足够空间)。日志文件还应该捕获所有 STDERR 消息,因此您不必重新运行被轰炸的程序只是为了查看错误消息是什么。
您使用的是 Linux/Unix,对吗?阅读您计算机上安装的 cp cmd 的手册页。我建议使用像
alias CP='/bin/cp -pi'
这样的别名,这样您始终可以使用相同的权限和原始文件的时间戳来复制文件。然后,可以轻松使用/bin/ls -ltr
查看排序的文件列表,其中最新的文件显示在列表底部。 (无需滚动回到顶部,按时间排序时,反向)。另外,“-i”选项会警告您将要覆盖文件,这已经帮我省了好几次了。我希望这有帮助。
PS,由于您似乎是新用户,如果您得到的答案对您有帮助,请记住将其标记为已接受,和/或给它 +(或 -)作为有用的答案。
My experience is that commandline copying is significantly faster (especially in the Windows environment). Of course the basic laws of physics still apply, a file that is 1000 times bigger than a file that copies in 1 second will still take 1000 seconds to copy.
Because I often have 5-10 projects that use similar directory structures, I set up variables for each subdir using a naming convention :
You can make this sort of thing as spartan or baroque as needed to match your theory of living/programming.
Then you can easily copy the cfg from 1 project to another
cp -p $NM_cfg/*.cfg ${altM_cfg}
Some people seem to really like that. You can try it and see what you thing.
Links to dirs are, in my experience used more for software development where a source code is expecting a certain set of dir names, and your installation has different names. Then making links to supply the dir paths expected is helpful. For production data, is just one more thing that can get messed up, or blow up. That's not always true, maybe you'll have a really good reason to have links, but I wouldn't start out that way, just because it is possible to do.
( Per above, use standardized directory structure for all projects.
Have scripts save any small files to a directory your dept keeps in the /tmp dir, .
i.e /tmp/MyDeptsTmpFile (named to fit your local conventions) )
It depends. If you're talking about data and logfiles, dated fileNames can save you a lot of time. I recommend dateFmts like YYYYMMDD(_HHMMSS) if you need the extra resolution.
Dated logfiles are very handy, when a current process seems like it is taking a long time, you can look at the log file from a week ago and quantify exactly how long this process took, a week, month, 6 months (up to how much space you can afford). LogFiles should also capture all STDERR messages, so you never have to re-run a bombed program just to see what the error message was.
This is Linux/Unix you're using, right? Read the man page for the
cp
cmd installed on your machine. I recommend using an alias likealias CP='/bin/cp -pi'
so you always copy a file with the same permissions and with the original files' time stamp. Then it is easy to use/bin/ls -ltr
to see a sorted list of files with the most recent files showing up at the bottom of the list. (No need to scroll back to the top, when you sort by time,reverse). Also the '-i' option will warn you that you are going to overwrite a file, and this has saved me more than a couple of times.I hope this helps.
P.S. as you appear to be a new user, if you get an answer that helps you please remember to mark it as accepted, and/or give it a + (or -) as a useful answer.