终端定时任务 开始缓冲

by Luciano Strika

通过卢西亚诺·斯特里卡(Luciano Strika)

如何开始使用终端以提高生产力 (How to start using the terminal to be more productive)

As developers, the terminal can be our second home.

作为开发人员,码头可以成为我们的第二故乡。

However, we can’t use it until we learn how to, and need to practice using it to learn, really — it’s a catch-22!

但是,只有在我们学习如何使用它之前,我们才能使用它,并且需要练习使用它来学习,这确实是一个陷阱-22!

I hope this introduction will solve that puzzle for you. I want to help you start making use of the terminal right away.

我希望本文能为您解决这个难题。 我想帮助您立即开始使用终端。

入门 (Getting Started)

I’ll cover the basics first, so if you know all the things in this article stay tuned for the next ones, where I’ll tackle more advanced topics.

我将首先介绍基础知识,因此,如果您知道本文中的所有内容,请继续关注下一篇,我将在其中讨论更高级的主题。

With that taken care of, I’ll start from the very beginning. If you’re on Ubuntu, all you have to do to open your terminal is press ctrl+alt+. On a Mac, you should press cmd+spacebar, start typing terminal and press enter when the option appears.

处理完这些后,我将从头开始。 如果您使用的是Ubuntu,则只需按ctrl + alt +即可打开终端 上 在Mac上,您应该按cmd +空格键,开始输入终端 ,然后在出现选项时按Enter。

In both cases, you should see a dark background with your username followed by your computer’s name (in Linux) or the reverse order (in a Mac).

在这两种情况下,您都应该看到黑色背景,其中包含用户名,后跟计算机名称(在Linux中)或相反的顺序(在Mac中)。

I strongly advise you to open your own terminal and try these commands out on an empty directory, to see for yourself and get the hang of them.

我强烈建议您打开自己的终端,并在一个空目录中尝试这些命令,以亲自看看并掌握其中的内容。

You’ll see a prompt inviting you to type commands. To enter a command just type it down and press enter. Some navigation commands are:

您会看到一个提示,邀请您键入命令。 要输入命令,只需将其键入,然后按Enter。 一些导航命令是:

cd:移动工作目录。 (cd : Moving your working directory.)

cd <relative path>

This will make your terminal point to a different directory, from which you can run new commands. For instance, if you’re in a folder called animals with three folders cats, dogs, and turtles, you’d run

这将使您的终端指向另一个目录,您可以从中运行新命令。 例如,如果您位于一个名为动物的文件夹中,而这三个文件夹为catdogs , 和海龟 ,你会跑

cd turtles

to move into that directory. To move up one level from the current directory (e.g., moving back to animals from turtles), hit

移到该目录。 要从当前目录上移一个级别(例如,从海龟移回动物 ),请点击

cd ..

mkdir并触摸:创建文件夹或文件。 (mkdir and touch: Creating folders or files.)

If you need to create a new, empty directory, all you have to do is run

如果您需要创建一个新的空目录,则只需运行

mkdir <directory name>

Whereas running

而跑步

touch <file_name>

will create an empty file in the current working directory, with the first argument as its name.

将在当前工作目录中创建一个空文件,并将第一个参数作为名称。

If another file with the given name already existed, this will only update the file’s last update date. It will not make any changes to its content.

如果已经存在具有给定名称的另一个文件,则只会更新文件的最后更新日期。 它不会对其内容进行任何更改。

‘But could I possibly know if the file exists?!’ You ask. Well, I’m glad you’re asking.

“但是我可能知道文件是否存在吗?!” 你问。 好吧,我很高兴你问。

ls:查看目录的内容。 (ls : See a directory’s contents.)

The ls command lists the name of every file and directory inside the current working directory, in alphabetical order. You can pass it a few arguments by using dashes, like this:

ls命令按字母顺序列出当前工作目录中每个文件和目录的名称。 您可以使用破折号向它传递一些参数,如下所示:

ls -a -l

In this case, the -a argument makes ls show invisible files. The -l command makes the output look like a list. It displays one row for each item, with some extra data like the size of each file or its creation date.

在这种情况下, -a参数使ls显示不可见的文件。 -l命令使输出看起来像一个列表。 它为每个项目显示一行,并带有一些额外的数据,例如每个文件的大小或其创建日期。

One of my favorite arguments for ls is -R, which recursively calls ls on each listed subdirectory for a quick look into a repository or file tree.

我对ls最喜欢的参数之一是-R,它递归地在每个列出的子目录上调用ls ,以快速查看存储库或文件树。

Note that for all commands, arguments can actually be combined after a single dash:

请注意,对于所有命令,参数实际上可以在短划线后合并:

ls -alR

Now I hear you asking ‘How in the world am I going to remember all of these arguments and options? Do all commands have so many crazy features?’But don’t worry — we got you covered.

现在,我听到您在问:“我将如何记住所有这些论点和选择? 所有命令是否都具有这么多疯狂的功能?'但请放心,我们已为您覆盖。

男人:永远不要停止学习! (man : Never stop learning!)

If you’ve been in Stack Overflow or Reddit, you’ve probably come across the phrase ‘read the man pages’ used either educationally or as an insult. I’m here for the first use.

如果您曾经在Stack Overflow或Reddit中学习过,您可能会碰到“读手册页”这两个词在教育上或侮辱性的使用。 我在这里是第一次使用。

Try running

尝试跑步

man <command name>

It will display that command’s man page — official documentation, with all of its possible arguments and uses. Most of us use it when we’re sure a certain program did something, but we can’t quite remember which flag made it do it. It’s also very good to call man on a command the first time you use it (for instance, if it shows up in a google result), to learn a bit more about it and maybe find better ways to invoke it. To close a man page, just press Q.

它将显示该命令的手册页-官方文档,以及所有可能的参数和用法。 我们大多数人在确定某个程序已执行某些操作时会使用它,但我们不记得是哪个标志使它执行了操作。 初次使用man时(例​​如,如果它出现在google结果中)调用man也是很好的,以了解更多有关它的信息,并可能找到更好的方法来调用它。 要关闭手册页,只需按Q。

头,尾巴,猫和更少:读取文件的内容。 (head and tail, cat and less : Read a file’s contents.)

Calling head or tail on a file will show you its first or last 10 lines, respectively.Some cool arguments you can call it with are:

调用文件的将分别显示其前10行或后10行。您可以使用以下一些很酷的参数来调用它:

  • -n <number>: display number lines instead of the default 10

    -n <数字 >: 显示 数字行而不是默认的10行

  • -f (for tail) : Show the lines in real time and don’t stop (perfect for keeping tabs on a log file when you ssh into a server)

    -f (用于tail ):实时显示各行,并且不停止(在ssh进入服务器时,可以在日志文件中保留制表符)

Calling cat will simply display a file’s content. Make sure you’re using it on actual text files, or you’ll see some trippy stuff.

呼叫cat只会显示文件的内容。 确保在实际的文本文件上使用它,否则会看到一些令人毛骨悚然的东西。

If you call cat on a large (or even large-ish, to be honest) file, you’ll probably find it pretty awkward to keep scrolling up and down, looking for the relevant lines. There’s actually a more convenient way of doing that: the less command.

如果你调用一个大型猫科动物 (甚至large- 十岁上下 ,要诚实)的文件,你可能会发现它非常尴尬,以保持向上和向下滚动,寻找相关线路。 实际上,有一种更方便的方法: 更少的命令。

less will show you less of a file by loading its contents in a buffered way. You can scroll the file with the arrow keys instead of using the mouse wheel/touchpad, which is a lot more comfortable. You can also press /, type something in and press Enter to search the file (like using ctrl+f).To exit less mode, just press Q.

less将以缓冲方式加载文件内容,从而显示较少的文件。 您可以使用箭头键滚动文件,而不是使用鼠标滚轮/触摸板,这更加舒适。 您也可以按/,输入内容,然后按Enter键搜索文件(例如使用ctrl + f )。要退出省模式,只需按Q。

cp和mv:复制,剪切和粘贴。 (cp and mv : Copy, cut and paste.)

cp (copy) and mv (move) are the bash equivalents to copy and cut, respectively. You can use them like this:

cp (复制)和mv (移动) 是分别复制剪切的bash等效项。 您可以像这样使用它们:

cp <source> <destination>

To copy the file(s) in source to destination.

源中的文件复制到目标。

The source can either be a file, or a set of files. To select more than one file, you can leverage bash’s wildcard character: *. This character will match any string, even an empty one.

源可以是一个文件或一组文件。 要选择多个文件,可以利用bash的通配符: * 。 此字符将匹配任何字符串,甚至是空字符串。

For instance, this command will copy all files in the some_folder folder into the some_other_folder folder, situated one level upwards in the file system.

例如,该命令将所有文件复制在some_folder文件夹放到some_other_folder文件夹,在文件系统位于一个指标向上。

cp some_folder/* ../some_other_folder

But if we wanted to only move the .txt files into a directory called texts, we’d use:

但是,如果我们只想将.txt文件移动到名为texts的目录中,则可以使用:

cp *.txt texts/

since * matches any string. Ee are enforcing its ending in .txt. (for instance, *.txt matches filename.txt, since * matches filename, but not filename.xtt, since even though * matches the whole name, there’s nothing that matches .txt).

因为*匹配任何字符串。 EE正在以.txt强制其结尾 (例如,* .TXT FILENAME.TXT相匹配因为*匹配文件名,但不filename.xtt,因为即使*匹配全名,没有什么是匹配.TXT)。

The destination can be a file’s path (overwriting the current file in that path, if it exists, or creating a new one otherwise) if the source is a single file, or a directory name if you wish to copy/move many files.

如果源是单个文件,则目标可以是文件的路径(如果存在,则覆盖该路径中的当前文件;否则,可以创建一个新文件);如果要复制/移动许多文件,则目标可以是目录名。

rm:删除文件和目录。 (rm : Deleting files and directories.)

The opposite of touch, rm deletes a file or directory.

触摸相反,rm删除文件或目录。

Using it in its default form

以其默认形式使用

rm file_name

will work when deleting a file, but throw an error when deleting a directory. This prevents us from deleting important files in a directory, or a whole directory thinking it’s just a file.

在删除文件时将起作用,但在删除目录时将引发错误。 这样可以防止我们删除目录中的重要文件,或认为它只是文件而删除整个目录。

To bypass this, if you feel courageous, just add -r, to recursively delete every file in a directory until it’s empty, before deleting it like some kind of serial deleter. If you only feel like deleting the empty directories, use -d instead.

要避免这种情况,如果您感到胆怯,只需添加-r,以递归方式删除目录中的每个文件,直到其为空为止,然后像某种串行删除器一样将其删除。 如果只想删除空目录,请使用-d

Note that you can always use the wildcard (*) character to delete many files or directories in a single command. For instance, calling

请注意,您始终可以使用通配符(*)删除单个命令中的许多文件或目录。 例如,打电话

rm *.txt

removes all text files from the current working directory.

从当前工作目录中删除所有文本文件。

结束...现在。 (The end… for now.)

Whew, that was some introduction. You’re now familiar with the most common commands you’ll be using in your daily programming life.

哇,那是一些介绍。 现在,您已经熟悉了日常编程生活中将要使用的最常见命令。

There are a lot of things I didn’t cover yet. I plan to make a follow up with more use cases, more commands and more real problems to solve.

我还没有涉及很多东西。 我计划跟进更多用例,更多命令和更多实际问题来解决。

While I prepare the next article, I’d like to encourage you to try these commands on your own. See which ones save you time, and get used to this whole terminal thing. Maybe bookmark this article and use it for reference. I won’t tell anyone.

在准备下一篇文章时,我鼓励您自己尝试这些命令。 看看哪些可以节省您的时间,并习惯于整个终端过程。 也许将本文添加为书签并用作参考。 我不会告诉任何人。

I promise you, after a while you’ll start to see why it’s worth it. (I know it took me a while). Eventually you’ll just instinctively open the terminal every time you start doing something.

我保证,一段时间后,您将开始明白它为什么值得。 (我知道花了一段时间)。 最终,每次您开始做某事时,您都会本能地打开终端。

I hope you found some of this introduction useful, and if so please let me know! I value my readers’ feedback a lot. This is the main reason I’m writing, so please tell me if some part was hard to understand, some commands seem useless, or my tutorial is simply too boring. Also let me know if some part was interesting!

希望本文对您有所帮助,如果是,请告诉我! 我非常重视读者的反馈意见。 这是我正在编写的主要原因,所以请告诉我是否有些部分难以理解,某些命令似乎无用,或者我的教程太无聊了。 还请让我知道某个部分是否有趣!

Part 2 is already available.

第2部分已经可用

Follow me for more programming tutorials, tips and tricks. You can also read my articles on www.datastuff.tech

跟我来了解更多编程教程,技巧和窍门。 您也可以在www.datastuff.tech上阅读我的文章

翻译自: https://www.freecodecamp.org/news/how-you-can-be-more-productive-right-now-using-bash-29a976fb1ab4/

终端定时任务 开始缓冲

终端定时任务 开始缓冲_如何开始使用终端以提高生产力相关推荐

  1. macbook 终端命令怎么使用_玩转 Terminal 终端:入门指南及进阶技巧

    怎样看出电影中哪个人是电脑大神?看他是不是在用终端. 这是句玩笑话,但是你可能或多或少从电影中见过某个电脑大神或者专业黑客,在一块黑色的窗口前随便敲一点代码,某个问题就迎刃而解了.虽然实际情况不会这么 ...

  2. linux终端删除文件命令_如何在Linux终端中删除文件和目录

    linux终端删除文件命令 Fatmawati Achmad Zaenuri/Shutterstock.comFatmawati Achmad Zaenuri / Shutterstock.com T ...

  3. tmux共享_最常用的终端工具 tmux

    tmux 是一个类似于 Screen 终端复用的工具,它能够在终端出现意外的情况下,确保你的程序还在继续运行,不会中断:还能够将一个终端窗口分离成多个会话,在多任务执行时,可以提供很大的便利. tmu ...

  4. pdcch加扰_一种基站/终端及其PDCCH加扰/解扰的方法和装置_2014104470078_权利要求书_专利查询_专利网_钻瓜专利网...

    1.一种物理下行控制信道PDCCH加扰方法,其特征在于,当基站系统支持集群数据业务时,所述方法包括: 按照预设的调度图谱调度集群数据业务或LTE数据业务: 对集群子帧上的集群数据业务使用集群无线网络临 ...

  5. java mcu 视频会议_详解视频会议终端和MCU的区别

    详解视频会议终端和MCU的区别 视频会议终端和MCU都是视频会议系统的核心组成部分之一,但其价格也相对高昂,是整个视频会议系统的主要成本之一.但是不熟悉视频会议系统的人,常常将视频会议终端和MCU无意 ...

  6. win7如何添加终端服务器,Windows7系统超级终端的添加方法 win7如何添加超级终端...

    有用户在刚升级到Windows7系统以后反映,在XP 操作系统里,超级终端是很好用的,但是却不知道为什么,升级为Windows7系统后却找不到超级终端在哪,出现这样的情况让用户非常的烦恼,其实找不到超 ...

  7. 工作回报如何影响人的生产力_如何在减少工作的同时提高生产力

    工作回报如何影响人的生产力 I don't have time to learn. 我没有时间学习. Many people say that to themselves. I say that to ...

  8. python终端界面分屏输出_linux命令 - screen/终端分屏命令

    与 tmux 工具较为类似,sreen 命令同样提供在唯一个的命令行终端上进行多窗口切换和管理的基本功能( 关于 tmux 基本操作可参见笔者的博文 终端复用工具 tmux 基本操作教程 ). scr ...

  9. 终端 删除php文件内容,Mac_mac命令行终端可以卸载吗?mac命令行终端卸载软件教程,  mac os系统卸载软件方式有 - phpStudy...

    mac命令行终端可以卸载吗?mac命令行终端卸载软件教程 mac os系统卸载软件方式有多种, 卸载工具,程序图标拖拽到垃圾桶皆可,但对顽固残留软件该怎么办呢?今天phpstudy小编就为大家分享ma ...

最新文章

  1. 服务化部署框架Paddle Serving
  2. 云计算的本质是什么?
  3. python生成日历书上哪里错了_python生成日历 - osc_a5pzxo31的个人空间 - OSCHINA - 中文开源技术交流社区...
  4. python脚本变成exe_Python脚本转exe文件
  5. Python爬虫自学之第(⑤)篇——爬取某宝商品信息
  6. Linux格式化异常,Linux下DateFormat的parse方法出现”ParseException”异常
  7. 华为交换机S3700端口基本配置
  8. [洛谷P5367]【模板】康托展开
  9. 数据分析学习记录--用EXCEL完成简单的单因素方差分析
  10. uniapp安卓创建桌面快捷方式
  11. 算法-枚举法-已知xyz + yzz = 532,其中x、y、z都是数字(0~9),编写一个程序求出x、y、z分别代表什么数字。
  12. 停止精神内耗 每日分享
  13. android 声音同步 测试,基于FFmpeg和Android的音视频同步播放实现
  14. 2019第二届中国天津国际智慧消防高峰论坛
  15. Linux shell脚本入门到实战详解(一)
  16. python如何取消换行_python怎么取消换行
  17. 再先进的在线教学,也要回归这个本质
  18. 华为:决定起诉美国政府
  19. 什么是「中华田园敏捷开发」,人才
  20. BZOJ2209 [Jsoi2011]括号序列

热门文章

  1. java数字排序代码,进阶加薪全靠它!
  2. 20101008 搬家
  3. clone-graph
  4. 添加远程链接MySQL的权限
  5. C#定义属性-静态属性
  6. 【写给朱大虫的教程】【Ruby on Rails】【006】遵循Rails理念的快速实现
  7. 作为微软技术.net 3.5的三大核心技术之一的WCF虽然没有WPF美丽的外观
  8. 如何使用fio模拟线上环境
  9. 【转】Android图片加载神器之Fresco-加载图片基础[详细图解Fresco的使用]
  10. DNN使用非80端口和总是跳转到http://localhost问题的解决