不能理解命令行选项 “n”

Today, I want to talk about something that I feel many people are either downright afraid of or at least outright hate using: the command line. It’s a beautiful tool once you learn how to use it, but for years, I could not bring myself to even try it — and it seriously hindered my programming journey.

今天,我想谈一谈我觉得很多人要么完全害怕使用,要么至少完全讨厌使用:命令行。 一旦您学会了如何使用它,它就是一个漂亮的工具,但是多年来,我什至无法尝试使用它-并且它严重阻碍了我的编程之旅。

So I want to show you not so much how to use it but rather why you should and what it is good for.

因此,我不想向您展示太多如何使用它,而是向您展示为什么要使用它以及它有什么好处。

太慢了,不是吗? 为什么不只使用鼠标? (It’s Just So Slow, Isn’t It? Why Don’t You Just Use the Mouse?)

Does this feel relatable? Each time you read a tutorial that starts with “bring up a command line,” you sigh, retire into your shell, realize your own inadequacy, the dire state of politics, and the world as a whole.

觉得相关吗? 每次阅读以“打开命令行”开头的教程时,您都会叹息,退休,意识到自己的不足,政治的严峻状况以及整个世界。

Believe me, I used to be there with you. I absolutely hated how slow and cumbersome it seemed to work with a black-and-white text editor. Now I love it. It feels sleek and downright enjoyable. So, yes, I’ve been there and I’ve been here and I can attest to the fact that it feels better to sleep on this side of the divide.

相信我,我曾经和你在一起。 我绝对不喜欢黑白文本编辑器的运行速度如此缓慢和麻烦。 现在我喜欢它。 感觉圆滑而令人愉悦。 所以,是的,我去过那里,我去过这里,我可以证明一个事实,那就是在鸿沟的这一侧睡觉会更好。

您可以更快地进行大规模运营 (You Can Do Mass Operations Much Faster)

For some reason, the hard drive that I use for my 3D rendering insists on making itself read-only every couple of days. I still have not figured out why, but that usually means that I can no longer save my currently open project, which — as you can guess — is not nice.

由于某种原因,我用于3D渲染的硬盘坚持要求每两天将其设为只读。 我仍然没有弄清楚为什么,但是通常这意味着我不能再保存我当前打开的项目,这(您可以猜到)不是很好。

Normally, I would need to go in and manually reset the attributes, taking at least ten minutes out of my day. Instead, I just open up a command line and type the following few lines:

通常,我需要花至少十分钟时间手动设置属性。 相反,我只是打开一个命令行并输入以下几行:

diskpartlist diskselect disk 1attributes clear disk readonly

This then reverts the whole hard drive to read-write mode in all of three seconds compared to the minutes it would take me using the regular Windows interface. Yes, that is clearly an issue where I am just fighting the symptoms instead of curing the cause, but right now, I don’t have another 5TB drive to back up my data before resetting the file system.

然后,与使用常规Windows界面所需的时间相比,这将使整个硬盘驱动器在三秒钟内全部恢复为读写模式。 是的,这显然是一个问题,我只是在解决症状而不是解决问题,但现在,在重置文件系统之前,我没有另一个5TB驱动器来备份我的数据。

您所做的一切都可以自动重用 (Everything You Do Can Be Automated for Reuse)

The command line is great for running quick scripts, but everything you do in it can also be automated using batch files.

命令行非常适合运行快速脚本,但是您在命令行中所做的所有操作也可以使用批处理文件自动执行。

Just write the same commands as you would, put them into a text file, and change the file extension to .bat. Congratulations, you can now run that script with either a double-click or by using your console to start it.

只需编写与命令相同的命令,然后将它们放入文本文件,然后将文件扩展名更改为.bat即可。 恭喜,您现在可以双击运行该脚本,也可以使用控制台启动该脚本。

Batch file syntax is not necessarily the easiest (it’s arguably the worst), but that doesn’t mean that a bit of Googling and cursing won’t get you where you want.

批处理文件的语法不一定是最简单的(可以说是最差的),但这并不意味着有些谷歌搜索和诅咒无法使您到达所需的位置。

For example, I have one batch script that compiles my Python scripts into executable files:

例如,我有一个批处理脚本,它将我的Python脚本编译为可执行文件:

pyinstaller --onefile ".\awesome_script.py"

And then I even have another batch file that loops through all recursive folders of my script folder and looks for compile.bat files to run them. As you can imagine, this saves a lot of time and more importantly prevents cases where my script.exe files aren’t current and up to date with the Python code I may have fixed in the meantime.

然后,我什至还有另一个批处理文件,该文件循环遍历脚本文件夹的所有递归文件夹,并寻找compile.bat文件来运行它们。 可以想象,这节省了很多时间,更重要的是防止了我的script.exe文件不是最新的并且与我同时修复的Python代码保持最新的情况。

控制台直接与系统连接,而不需要走风景线 (The Console Interfaces Directly With the System Instead of Taking the Scenic Route)

Have you ever tried deleting or copying a huge folder on Windows? Have you noticed it taking so long that you think about early retirement more than usual?

您是否曾经尝试在Windows上删除或复制一个巨大的文件夹? 您是否注意到花了这么长时间以至于比平时更想早退休?

Well, do the same with the console by typing:

好吧,通过键入以下命令对控制台执行相同的操作:

xcopy "path/to/source/" "path/to/destination/"

And you can watch the system run through the tasks at menacing speeds — several times faster than using the Windows explorer. Now you can call that stupid. I’m sure that anti-Windows snobs will find that hilarious because their superior operating system does not have that quirk. But to me, this is the way things are, and having a much faster workaround has saved me hours and days at work during a large migration project we had.

您可以看到系统以惊人的速度运行任务-比使用Windows资源管理器快几倍。 现在,您可以称其为愚蠢的。 我敢肯定,反Windows势利小人会觉得很有趣,因为它们的高级操作系统没有这种怪癖。 但是对我来说,事情就是这样,而更快的解决方法为我节省了一个大型迁移项目所需的时间和时间。

它使您在做某事之前先三思 (It Makes You Think Before You Do Something)

This is more of a “soft benefit,” but I realize that I work a lot more purposefully whenever I have a console in front of me. When I use the mouse, I’m instantly bored and start “mousing around” on the hunt for the menu I’m looking for, then I lose track and switch over to Chrome to search for music that can make this endeavour less painful.

这更多是“软收益”,但是我意识到,只要有控制台在我面前,我就会更有目标地工作。 当我使用鼠标时,我立即感到无聊,开始在寻找菜单上寻找鼠标,然后迷路了,切换到Chrome浏览器搜索音乐,以减轻痛苦。

I’m kidding a bit, of course, but there is truth in that. By using the console, you are much more focused on the task at hand — and you think before you type.

当然,我在开玩笑,但这是真的。 通过使用控制台,您可以更加专注于手头的任务-并在键入之前进行思考。

它具有隐藏的功能,大多数用户无法访问 (It Has Hidden Functions Most Users Don’t Have Access To)

Remember that diskpart thing I mentioned earlier? Most people would not even know of it or know how to search for something that automates read-only attribute reversals.

还记得我之前提到的diskpart吗? 大多数人甚至不知道它,也不知道如何搜索自动执行只读属性反转的操作。

But just by knowing batch exists, I can do just that:

但是只要知道批处理存在,我就可以做到:

google "batch mass set readonly"or google “batch set drive readonly”

谷歌“批量设置只读”或谷歌“批量设置驱动器只读”

And there are so many more. For example, you can mass-rename files, you can create for and while loops, and do a surprising lot of things. I use batch scripts every day to use the denoising app to clean up rendered images, and being able to do that saves me literally hours a day since I can render images at 300 instead of 1k samples with the same result.

还有更多。 例如,您可以批量重命名文件,可以创建forwhile循环,并可以做很多令人惊讶的事情。 我每天都使用批处理脚本来使用去噪应用程序来清理渲染的图像,并且能够做到这一点每天节省了我数小时的时间,因为我可以渲染300次而不是1000个样本的图像而获得相同的结果。

你可以抽烟斗 (You Can Smoke a Pipe)

Piping is one of the most powerful features of the command line because it lets you pass the output of one program into another, effectively chaining commands and tools together into one script.

配管是命令行最强大的功能之一,因为它使您可以将一个程序的输出传递到另一个程序,从而将命令和工具有效地链接到一个脚本中。

generateReport.bat > reportToExcelFile.bat

Read more about piping and chaining in this how-to.

在本操作指南中阅读有关管道和链条的更多信息。

A coworker of mine made heavy use of this to have true incremental commits where they had a command-line script that would take each changed file, commit using the same overall commit message with the issue ID and the file name in the title, and then once they were all done, they would push the changes to the remote branch.

我的一个同事大量使用了此方法,以实现真正的增量提交,在这种情况下,他们拥有一个命令行脚本,该脚本将获取每个更改的文件,使用具有问题ID和标题中文件名的相同总体提交消息进行提交,然后完成所有操作后,他们会将更改推送到远程分支。

自动完成功能使命令行使用合理快速 (Autocomplete Makes Command-Line Usage Reasonably Fast)

After a while, you really get the hang of using the keyboard to navigate your file system. In essence, there are only two commands you need:

一段时间后,您真的可以使用键盘导航文件系统了。 本质上,您只需要两个命令:

  • cd (change directory) will let you jump into a subfolder of your current folder — or you can jump up one level by typing cd ..

    cd (更改目录)将使您跳至当前文件夹的子文件夹-或通过键入cd .跳至上一级cd .

  • dir will show you a list of all available files and subfolders inside a folder, letting you know which files you want to access.

    dir将显示文件夹中所有可用文件和子文件夹的列表,让您知道要访问哪些文件。

After that, you can always type the first few letters of the path, then use tab to either autocomplete or toggle through the available options. Hit enter and it all works. After a while, this becomes very fast and second nature. Everything else, you either learn or Google as you need it.

之后,您始终可以输入路径的前几个字母,然后使用Tab键自动完成或在可用选项之间切换。 按Enter键,一切正常。 一段时间后,这变得非常快,成为第二自然。 您可以根据需要学习或学习其他所有内容。

您消除人为错误 (You Take Out the Human Error)

This may sound weird with so much typing and that many chances to make typos, but that’s precisely the weird beauty of it. When you type something and do it wrong, then things won’t work — and you will get an error message.

这么多的打字听起来很奇怪,并且有很多机会打错字,但这恰恰是它的怪异之美。 当您键入某些内容并输入错误时,该内容将无法正常工作,并且您会收到一条错误消息。

You will never have the wrong path because then your script won’t even autocomplete to the right directory where you want to run your script.

您永远不会有错误的路径,因为这样您的脚本甚至都不会自动完成到要运行脚本的正确目录。

This comes into effect a lot more when it comes to tutorials. Now you have a standard that anyone can follow at their own pace instead of having someone search for menus on screen for two minutes in a screencast and then miss the right option, driving you crazy as you watch them struggle. It’s best to use the console and avoid anger management issues.

当涉及到教程时,这会更加有效。 现在,您有了一个标准,任何人都可以按照自己的节奏进行操作,而不是让某人在屏幕录像中搜索屏幕菜单两分钟,然后错过正确的选项,从而使您在观看他们的斗争时发疯。 最好使用控制台并避免愤怒管理问题。

Plus, of course, you can copy-paste console commands instead of painstakingly recreating the steps that this annoyingly helpful person did when they set down and spent time, effort, and money trying to help others.

另外,当然,您可以复制粘贴控制台命令,而不用费力地重新创建这个烦人的人在设置下来并花费时间,精力和金钱尝试帮助他人时所执行的步骤。

你看起来像个黑客 (You Look Like a Hacker)

While obviously a joke, this should not be underestimated. Faking your way through a meeting has actual, palpable benefits. Just reach for your keys and start playing a little keyboard solo as you try to bring your point across in a meeting and you’ll immediately notice that all the right-wrong people are wooed by your immense skills.

虽然这显然是个玩笑,但这不应该被低估。 假装开会确实有明显的好处。 当您试图在会议中表达自己的观点时,只需伸开键并开始独奏一个小键盘,您就会立即注意到,所有对错的人都被您的丰富技能所吸引。

I have made this realization time and time again, and after a while, I stopped feeling like a cheat, as I realized that this is exactly what Sherlock Holmes does: He impresses his clients and bystanders needlessly not to brag but to establish his expertise and allow himself to work faster and with fewer distractions. He also gets people to listen to him, whereas they would ridicule others for the same attempts and conclusions.

我一次又一次地意识到这一点,过了一段时间,我不再觉得自己像个骗子,因为我意识到这正是夏洛克·福尔摩斯所做的:他给客户和旁观者留下了不必要的印象,而不是吹牛,而是建立了自己的专业知识和让自己更快地工作,减少干扰。 他还会使人们听他的话,而他们会嘲笑其他人以同样的尝试和结论。

There is real value in this. I have used it several times to bring meetings that were hopelessly spiraling out of control back on track— and all I did was navigate into a folder to open a .exe file or something instead of using the mouse.

这是真正的价值。 我已经多次使用它来使无法控制的螺旋式会议重新回到正轨上,而我所做的只是导航到一个文件夹中以打开.exe文件或其他内容,而不是使用鼠标。

简介:命令行是可以为您的生产力带来奇迹的工具 (Summary: The Command Line Is a Tool That Can Do Wonders for Your Productivity)

I hope I could show you a small glimpse into the basic benefits of the command line and why it is still a thing in the time of touch screens and mouse input.

希望我能向您简要介绍一下命令行的基本优点,以及为什么在触摸屏和鼠标输入时仍然如此。

And if you like, you can enter the dark void of people who can lead flamewars over which terminal, console, or command-line tools are vastly superior. There are a lot of advanced things that I could not even begin to fit into this article.

而且,如果您愿意,您可以进入一个黑暗的人群,他们可以领导一场激烈的战争,而终端,控制台或命令行工具在这方面是极为优越的。 有很多高级的东西我什至无法开始适合本文。

翻译自: https://medium.com/better-programming/how-to-understand-the-command-line-448cf864dc43

不能理解命令行选项 “n”


http://www.taodudu.cc/news/show-4040073.html

相关文章:

  • 命令行帮助文档语法格式详解
  • EXPDP命令行选项
  • Oracle安装过程中出现的错误指令
  • win764位loadrunner安装问题:提示:少了Microsoft Visual c++2005 sp1运行时组件,安装时会提示命令行选项语法错误,键入“命令/?”可获取帮肋信息,无法正常安装;
  • linux 命令行语法错误,sudo命令:解决使用Linux命令行时出现的错误提示
  • 计算机键入命令,Win7系统安装软件提示命令行语法错误键入“ 命令/?”怎么办...
  • loadrunner icrosoft Visual c++2005 sp1 提示命令行选项语法错误,键入“命令/?”
  • loadrunner icrosoft Visual c++2005 sp1运行时组件,就会提示命令行选项语法错误,键入“命令/?”
  • 安装loadrunner11的时候提示'命令行选项语法错误。键入命令 / ?’ 怎么办
  • 安装LR11 时,安装Microsoft Visual c++2005 sp1运行时组件,就会提示命令行选项语法错误,键入“命令/?”可获取帮肋信息
  • 安装loadrunner时出现”命令行选项语法错误键入命令 \?获得帮助“的解决方法
  • 计算机键入命令,win7系统安装软件出现命令行选项语法错误键入“ 命令/?”怎么办...
  • 烧不进固件处理方法
  • 从安卓/linux固件反编译出dtb和dts
  • 3.2.2 nodeMCU固件烧录
  • jetson agx xavier 系统源码编译及固件烧写
  • UBOOT下自定义显示BMP图片
  • 基于F4/F7/H7飞控硬件和px4飞控固件的廉价自主无人机系统(1)-飞控
  • html rfftq15.gif,STM32F4系列完整固件库
  • 路畅安卓最新固件升级_【精】2017.11.10日更新 路畅软件升级,最新版4.0.9 更新【郑重声明】...
  • esp8266烧录html方法,将ESP8266刷成可以使用网页配置的固件和步骤
  • iNav飞控AOCODARC-F7MINI固件编译
  • 基于F4/F7/H7飞控硬件和px4飞控固件的廉价自主无人机系统(2)- 外设和固件修改
  • html rfftq15.gif,STM32F4xx固件库
  • 哇哦!?固件裁剪到1.82K? 他们是怎么做到的?
  • Marlin固件的欢迎界面
  • LibOpenCM3(二) 项目模板 Makefile分析
  • 全志定制编译Android,全志H3 Android定制化文档
  • Android常用固件修改
  • 2. ESP8266固件的编译(nodemcu固件)

不能理解命令行选项 “n”_如何理解命令行相关推荐

  1. 安装LoadRunner 11时弹窗提示Micosoft Visual C++ 2005 SP1 可再发行组件包(X86):'命令行选项语法错误。键入命令 / ? 可获得帮助信息'。

    如果安装LoadRunner 11时弹窗提示"Micosoft Visual C++ 2005 SP1 可再发行组件包(X86):'命令行选项语法错误.键入命令 / ? 可获得帮助信息'&q ...

  2. 安装LR11 时,安装Microsoft Visual c++2005 sp1运行时组件,就会提示命令行选项语法错误,键入“命令/?”可获取帮肋信息...

    1.进入loadrunner-11\Additional Components\IDE Add-Ins\MS Visual Studio .NET  2.安装:LRVS2005IDEAddInSetu ...

  3. getopt:命令行选项、参数处理

    getopt:命令行选项.参数处理 2014-01-11 Posted by yeho 在写shell脚本时经常会用到命令行选项.参数处理方式,如: ./test.sh -f config.conf ...

  4. 命令行选项解析函数:getopt()

    1.定义: int getopt(int argc, char * const argv[], const char *optstring); 2.描述: getopt是用来解析命令行选项参数的,但是 ...

  5. 命令行选项解析函数(C语言):getopt()和getopt_long()

    上午在看源码项目 webbench 时,刚开始就被一个似乎挺陌生函数 getopt_long() 给卡住了,说实话这函数没怎么见过,自然不知道这哥们是干什么的.于是乎百度了一番,原来是处理命令行选项参 ...

  6. 命令行选项解析函数(C语言):getopt()和getopt_long()【转】

    (转自:https://www.cnblogs.com/chenliyang/p/6633739.html) 上午在看源码项目 webbench 时,刚开始就被一个似乎挺陌生函数 getopt_lon ...

  7. python 基础命令-详解python常用命令行选项与环境变量

    一.命令行选项 1.解释器选项 python的解释器非常像unix的shell,在我们使用python的过程中,我们可以指定很多的选项. 比如,最常用的选项如下: python script.py 在 ...

  8. python add argument list_python模块介绍- argparse:命令行选项及参数解析

    #承接软件自动化实施与培训等gtalk:ouyangchongwu#gmail.com qq 37391319 博客: http://blog.csdn.net/oychw #版权所有,转载刊登请来函 ...

  9. ccf命令行选项只能用c实现_CCF-201403-3-命令行选项

    问题描述 试题编号: 201403-3 试题名称: 命令行选项 时间限制: 1.0s 内存限制: 256.0MB 问题描述: 问题描述 请你写一个命令行分析程序,用以分析给定的命令行里包含哪些选项.每 ...

  10. 【Python】Python3.7.3 - sys.flag 命令行选项标志结构序列

    文章目录 Python命令行完整选项 sys.flag - Python启动命令行选项标志 Python命令行完整选项 https://blog.csdn.net/qq_43401808/articl ...

最新文章

  1. 使用Python、OpenCV进行图像接缝雕刻
  2. Spring和MyBatis环境整合
  3. 职业生涯又一个转折点
  4. Calendar日历小程序
  5. 思考:用开发移动app的观念来开发网站
  6. 数字滚动_告别单调!让PPT数字滚动起来。
  7. python 单例模式
  8. 获取指定存储过程的参数定义
  9. 直方图中最大的矩形(单调栈2)
  10. 面试复习笔记二(javaweb)
  11. 341编程器 软硬件
  12. 车辆加速性能测试软件,汽车动力性能检测
  13. 15亿参数的NLP模型究竟有多强大?有人用它生成了一部《哈利·波特》
  14. matlab gui设计入门与实战,matlab gui编程教程
  15. java生成二维码扫描跳转到指定的路径URL
  16. 《深入理解计算机系统》学习笔记:程序的机器级表示
  17. 瑞利信号公式(级联信道,多信道之和,多个瑞利信号之和,概率密度函数)
  18. Debian安装谷歌浏览器(Google Chrome)
  19. CF终于上紫了。。。
  20. java培训北大青鸟大兴校区_北大青鸟大兴校区毕业典礼报道!

热门文章

  1. Vue+ElementUI中的input输入框添加自定义图片
  2. tf.contrib.silm学习
  3. python 005 __ 小斌文档 | 函数的定义和调用
  4. 深入理解:面向服务与微服务架构
  5. 【深度学习6】对比学习(Contrastive Learning)入门
  6. 微信Android热补丁实践演进之路
  7. MySQL面试夺命连环27问
  8. date.getMonth() date.getDate())
  9. 信息检索与利用(第三版)第二章信息资源与信息源
  10. Windows常见垃圾清理方式