热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何使用UnixCLI有效地学习工作-HowtolearnworkeffectivelywithUnixCLI

DoyouknowanyresourcesthatteachtogoodhabitsofworkinginUNIXcommandline?您是否知道任何教授在UNIX命

Do you know any resources that teach to good habits of working in UNIX command line?

您是否知道任何教授在UNIX命令行中工作的良好习惯的资源?

EDIT: I don't mean general books about shell or man pages. I mean the things that you can only see watching professionals working with command line. For example when changing frequently between two directories they use "pushd" command, when repeating a command they use "history". I can read about these commands but I want to make it a habit to use them effectively.

编辑:我不是指关于shell或man page的一般书籍。我的意思是你只能看到看专业人员使用命令行的东西。例如,当在两个目录之间频繁更改时,他们使用“pushd”命令,当重复命令时,他们使用“历史”。我可以阅读这些命令,但我想养成有效使用它们的习惯。

9 个解决方案

#1


7  

I am speaking out of my own experience so it may not apply to you;

我说的是出于我自己的经历,所以它可能不适用于你;

The best way to be efficient is actually using it on a daily basis, instead of using graphical tools even if they make look things easy. You will then become aware of most common tasks you care about, and instead of trying to grok it at once, you get a fairly good starting point to start learning. Man pages are the first thing to look at, but there will be non-obvious tricks which you need to search anyway. Knowing what you exactly want, infinitely increases probability of finding it.

提高效率的最佳方式实际上是每天使用它,而不是使用图形工具,即使它们使外观变得容易。然后,您将意识到您关心的大多数常见任务,而不是试图立即完成任务,您将获得一个相当不错的起点来开始学习。手册页是首先要看的东西,但无论如何都需要搜索非显而易见的技巧。知道你究竟想要什么,无限增加找到它的概率。

For example, you can find how to search all mp3 files easier in man page of "find" than how to deal with files in general (where to start?).

例如,您可以在“查找”的手册页中找到如何更轻松地搜索所有mp3文件,而不是如何处理一般文件(从哪里开始?)。

#2


4  

Some common bash command line actions, not in order:

一些常见的bash命令行操作,而不是按顺序:

  • Command line editing: you'll want to be good with emacs or vi and apply that to editing your commands.
  • 命令行编辑:您希望熟悉emacs或vi并将其应用于编辑命令。

  • Completion: use TAB to expand file names and paths.
    • note: There is a huge set of file, command, and history completion functions, and it is configurable. Big topic.
    • 注意:有大量的文件,命令和历史记录完成功能,它是可配置的。大话题。

  • 完成:使用TAB扩展文件名和路径。注意:有大量的文件,命令和历史记录完成功能,它是可配置的。大话题。

  • "cd -" : go back to the last directory you were in
  • “cd - ”:回到你所在的最后一个目录

  • ~ = home directory (or ~user for users home dir)
  • 〜=主目录(或用户主目录的〜用户)

  • "ESC ." : expands to the final arg from the previous command
  • “退出 。” :从上一个命令扩展到最终的arg

  • "!string" : execute the last command starting with string
  • “!string”:执行以string开头的最后一个命令

  • learn find, grep, sed, piping "|" and redirection ">". You'll often combine these to do useful things.
  • 学习查找,grep,sed,管道“|”和重定向“>”。你经常将这些结合起来做有用的事情。

  • Loops from the shell prompt, e.g. "for" loop - to do repetitive actions
  • 来自shell提示符的循环,例如“for”循环 - 做重复动作

  • Learn your regular expressions! Often used for matching files.
    • example: ls x[0-5]*.{zip,tar} = list files starting with x, followed by a number 0 through 5, followed by any string ending in .zip or .tar
    • 示例:ls x [0-5] *。{zip,tar} =以x开头的列表文件,后跟数字0到5,后跟任何以.zip或.tar结尾的字符串

  • 学习正则表达式!通常用于匹配文件。示例:ls x [0-5] *。{zip,tar} =以x开头的列表文件,后跟数字0到5,后跟任何以.zip或.tar结尾的字符串

If possible ask others for their favorite tricks, read the manual, and practice.

如果可能的话,请向他人询问他们最喜欢的技巧,阅读手册和练习。

#3


3  

For the more advanced stuff This seems to be fairly comprehensive

对于更高级的东西这似乎是相当全面的

#4


3  

this is a great resource: "Rute User's Tutorial and Exposition" (http://rute.2038bug.com/index.html.gz)

这是一个很好的资源:“Rute User's Tutorial and Exposition”(http://rute.2038bug.com/index.html.gz)

#5


1  

stackoverflow.com esp. the bash tag ;-) (and of course the bash man page)

stackoverflow.com尤其是bash标签;-)(当然还有bash手册页)

#6


1  

If you want things that you can "only see watching professionals working with command line," then you've answered your own question: Watch professionals working with the command line. I don't personally find that very useful unless the other person is doing the same thing multiple times; it's hard to pick something up after just one session because it's hard to watch the screen and the keyboard at the same time.

如果你想要的东西“你只能看到专业人士使用命令行”,那么你已经回答了自己的问题:观看使用命令行的专业人士。除非另一个人多次做同样的事情,否则我个人并不觉得这非常有用;在一次会议之后很难选择一些东西,因为很难同时观看屏幕和键盘。

I think the key is to not try to become an expert right away. Just use the command line frequently, and be aware that you might not be using it as well as you could, but don't let that discourage you from using it anyway.

我认为关键是不要试图立即成为专家。只需经常使用命令行,并注意您可能没有尽可能使用它,但不要让它阻止您使用它。

Browse through the man page of your shell, and through lists of tips, not with the goal of memorizing everything in them, but just to pick out a couple of things to try out. Skim through until something catches your eye and makes you think, "Gee, that sounds useful." Then try it out. Not everything is going to be useful immediately; you might have to wait a while before you encounter a situation where you can try something out. Maybe you could write down some things on Post-It notes by your desk to remind you that certain feats are possible, so when you encounter a situation where a more obscure feature could be handy, you'll be more likely to remember to try it.

浏览shell的手册页,以及提示列表,而不是记住其中的所有内容,而只是选择要尝试的一些内容。浏览一下,直到某些东西吸引你的眼球并让你思考,“哎呀,听起来很有用。”然后尝试一下。并非一切都会立即发挥作用;你可能需要等待一段时间才能遇到可以试一试的情况。也许你可以在你的桌子上写下Post-It笔记上的一些东西来提醒你某些功能是可能的,所以当你遇到一个更加模糊的功能可能很方便的情况时,你会更有可能记得尝试它。

#7


1  

Frankly, it's impossible to learn this stuff in a vacuum. You need to have problems to solve.

坦率地说,在真空中学习这些东西是不可能的。你需要解决问题。

While it certainly helps to have familiarity with the tools available (of which there are a myriad), "learning" it requires applying it. And applying it requires "real" problems to solve.

虽然熟悉可用的工具(其中有无数的工具)肯定有帮助,但“学习”它需要应用它。应用它需要“真正的”问题来解决。

For example, the skillset of a System Admin may be different from someone who works with databases because their roles are different.

例如,系统管理员的技能组可能与使用数据库的人不同,因为他们的角色不同。

I use them for data processing, using mostly one off files. /tmp/x.sh and /tmp/x.x are worn bare in the directory folder.

我使用它们进行数据处理,主要使用一个off文件。 /tmp/x.sh和/tmp/x.x裸露在目录文件夹中。

My hammers tend to lean towards: ls, find, sort, sed, vi, awk, grep, and comm. Combined with simple shell scripting like: for i in cat /tmp/list; do .. done

我的锤子往往倾向于:ls,find,sort,sed,vi,awk,grep和comm。结合简单的shell脚本,例如:for cat in cat / tmp / list;做..完成

But I do a lot of ETL work, and very few script files, which is why my shell scripting skills are so weak.

但是我做了很多ETL工作,而且脚本文件很少,这就是我的shell脚本技能如此薄弱的原因。

I do rely on one script, however:

但我确实依赖一个脚本:

#!/bin/sh
# latest -- show latest files
ls -lt $@ | head

As 95% of the time the files I'm working on are in the top 10 latest files. And "latest *.txt" works a peach.

95%的时间我正在处理的文件位于前10个最新文件中。并且“最新的* .txt”是一个桃子。

So, bottom line, you need problems to solve. You need to learn the 'man' command, man -k is nice to find things. You also need to leverage the "See Also" at the bottom of most man pages. That's a treasure trove of "I didn't know you could do that".

所以,底线,你需要解决的问题。你需要学习'man'命令,man -k很高兴找到东西。您还需要利用大多数手册页底部的“另请参阅”。这是“我不知道你能做到”的宝库。

Then, just start solving problems. Start figuring out "what would be nice to have" and then see if it exists (it very well may). If not, awk, perl, or python can make those "nice to haves" out of thin air.

然后,开始解决问题。开始弄清楚“有什么好处”,然后看看它是否存在(很可能)。如果没有,awk,perl或python可以凭空捏造那些“好看的东西”。

#8


0  

Join a LUG. That is where I learned most things early on. Ask the organizers to do a "Bash Tips And Tricks Night".

加入LUG。这是我早期学到大部分东西的地方。要求组织者做一个“Bash Tips and Tricks Night”。

Deft shell users love to show off.

Deft shell用户喜欢炫耀。

#9


0  

apropos is a really good tool for this sort of thing. Whenever you find yourself unsure of the best way to do something, or wishing you weren't repeating yourself, just use apropos with a keyword or two to find other commands that can help. In distros like debian, you can also install web-based help tools that search all of the manuals available on the system: texinfo, man pages, html, and pdf etc.

apropos对于这类事情来说是一个非常好的工具。每当你发现自己不确定做某事的最佳方式,或者希望你不重复自己时,只需使用带有关键字或两个关键字的apropos来找到可以提供帮助的其他命令。在像debian这样的发行版中,您还可以安装基于Web的帮助工具,搜索系统上可用的所有手册:texinfo,手册页,html和pdf等。

Aside from that, yep, read your shell's manual right through at least once --- preferably, go back to repeatedly it as you learn more, reach limits and want to be more efficient.

除此之外,是的,请至少阅读一次你的shell手册 - 最好,在你了解更多,达到极限并希望提高效率的同时,重复它。

The join a LUG idea is also good; you'll definitely learn from others' demos.

加入LUG的想法也很好;你肯定会从别人的演示中学习。


推荐阅读
author-avatar
是冉冉升起的冉啊
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有