終端定時任務 開始緩沖_如何開始使用終端以提高生產力

終端定時任務 開始緩沖

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/

終端定時任務 開始緩沖

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/393493.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/393493.shtml
英文地址,請注明出處:http://en.pswp.cn/news/393493.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

圖片預覽------photoswipe 使用

photoswipe 使用 預覽圖片后&#xff0c;需要點擊關閉按鈕才能關閉&#xff0c;點擊圖片事件效果是放大圖片&#xff0c;和微信的效果不一致&#xff0c;最后改用微信預覽圖片的接口了&#xff0c;但是例子可以用&#xff0c;記錄一下&#xff01;&#xff01; http://www.cnbl…

SSKeychain

Keychain 使用? ---為了實用最大化我覺得我應該直接先說使用&#xff01; 當然是使用第三方庫啦&#xff1a;sskeychain 3000星星的庫不開玩笑。github地址&#xff1a;https://github.com/soffes/sskeychain 導入完之后首先&#xff0c;編譯一下有無錯。 如果是自己手動導入&…

shell高級-----正則表達式

正則表達式概述 正則表達式是一種定義的規則&#xff0c;Linux工具可以用它來過濾文本。 基礎正則表達式 純文本 [rootnode1 ~]# echo "this is a cat" | sed -n /cat/p this is a cat [rootnode1 ~]# echo "this is a cat" | gawk /cat/{print $0} this …

leetcode130. 被圍繞的區域(bfs)

給定一個二維的矩陣&#xff0c;包含 ‘X’ 和 ‘O’&#xff08;字母 O&#xff09;。 找到所有被 ‘X’ 圍繞的區域&#xff0c;并將這些區域里所有的 ‘O’ 用 ‘X’ 填充。 示例: X X X X X O O X X X O X X O X X 運行你的函數后&#xff0c;矩陣變為&#xff1a; X X…

linux mysql提交_MySQL 事務提交過程

開發老大要求通過binlog查詢一條被修改的數據&#xff0c;數據被查出后問我&#xff0c;有沒有可能binlog中不會記錄&#xff0c;回答不會&#xff0c;因為數據被修改&#xff0c;若失敗直接回滾&#xff0c;不會在binlog中記錄&#xff0c;此刻一個朋友用了洪荒之力告訴我&…

spray.json_如何使用Spray-json(Un)在Akka HTTP中封送JSON

spray.jsonby Miguel Lopez由Miguel Lopez 如何使用Spray-json(Un)在Akka HTTP中封送JSON (How to (Un)marshal JSON in Akka HTTP with spray-json) In the previous post, we added JSON support to our Akka HTTP API using circe.在上一篇文章中 &#xff0c;我們使用circ…

React單元測試:Jest + Enzyme(二)

前言 在上一篇教程中&#xff0c;我們成功搭建了基于Jest和Enzyme的單元測試框架并成功地跑起來第一個單元測試&#xff0c;可以點擊這里回顧一下。今天&#xff0c;我們重點討論如何通過Jest來mock數據。 什么是Mock Mock的簡單翻譯就是模擬。既可以模擬數據&#xff0c;也可以…

input file 文件上傳,js控制上傳文件的大小和格式

文件上傳一般是用jquery的uploadify&#xff0c;比較好用。后面會出文章介紹uploadify這個插件。 但是&#xff0c;有時候為了偷懶&#xff0c;直接就用input 的file進行文件和圖片等的上傳&#xff0c;input file 可以控制上傳的格式&#xff0c;但是是html5&#xff0c;很多瀏…

leetcode面試題 17.08. 馬戲團人塔(二分法)

有個馬戲團正在設計疊羅漢的表演節目&#xff0c;一個人要站在另一人的肩膀上。出于實際和美觀的考慮&#xff0c;在上面的人要比下面的人矮一點且輕一點。已知馬戲團每個人的身高和體重&#xff0c;請編寫代碼計算疊羅漢最多能疊幾個人。 示例&#xff1a; 輸入&#xff1a;…

如何選擇適合自己的CMS建站系統

如今做網站已不像過去那樣必須找網站公司才能建&#xff0c;因為網上針對建站的各種CMS建站系統層出不窮。像PageAdmin、DEDECMS、帝國CMS、Discuz等&#xff0c;這些CMS系統各有各的特點和優勢&#xff0c;小熊優化的小編我從事網站制作和網站優化多年&#xff0c;和很多建站朋…

python dict hash算法_2020年3月26日python學習筆記——hash

什么是哈希&#xff1f;hash,一般翻譯做散列、雜湊&#xff0c;或音譯為哈希&#xff0c;是把任意長度的輸入(又叫做預映射pre-image)通過散列算法變換成固定長度的輸出&#xff0c;該輸出就是散列值。這種轉換是一種壓縮映射&#xff0c;也就是&#xff0c;散列值的空間通常遠…

數據處理不等式:Data Processing Inequality

我是在差分隱私下看到的&#xff0c;新解決方案的可用性肯定小于原有解決方案的可用性&#xff0c;也就是說信息的后續處理只會降低所擁有的信息量。 那么如果這么說的話為什么還要做特征工程呢&#xff0c;這是因為該不等式有一個巨大的前提就是數據處理方法無比的強大&#x…

aws架構_如何使用AWS構建可擴展架構

aws架構What I learned building the StateOfVeganism ?我學到的建立素食主義的方法是什么&#xff1f; By now, we all know that news and media shape our views on the topics we discuss. Of course, this is different from person to person. Some might be influence…

gulp 實現sass自動化 ,監聽同步

實現功能 監聽scss文件   sass自動化 準備條件 1 .安裝gulp npm init ---->一直enter&#xff0c;會在當前目錄下生成一個package.json文件,記錄安裝的依賴模塊 npm install gulp --save-dev 2 .安裝gulp-ruby-sass npm install gulp-ruby-sass 你還需要安裝ruby環境…

leetcode面試題 10.03. 搜索旋轉數組(二分法)

搜索旋轉數組。給定一個排序后的數組&#xff0c;包含n個整數&#xff0c;但這個數組已被旋轉過很多次了&#xff0c;次數不詳。請編寫代碼找出數組中的某個元素&#xff0c;假設數組元素原先是按升序排列的。若有多個相同元素&#xff0c;返回索引值最小的一個。 示例1: 輸入…

MSSQL → 02:數據庫結構

一、數據庫的組成 在SQL Server 2008中&#xff0c;用戶如何訪問及使用數據庫&#xff0c;就需要正確了解數據庫中所有對象及其設置。數據庫就像一個容器&#xff0c;它里面除了存放著數據的表之外&#xff0c;還有視圖、存儲過程、觸發器、約束等數據庫對象。數據庫管理的核心…

JAVA拳皇_拳皇(Java簡單的小程序)代碼實例|chu

剛開始學習Java&#xff0c;看完老九君的視頻根據他的內容敲的代碼&#xff0c;感覺還挺有成就感的&#xff0c;畢竟剛學習Java。package helloasd;import java.util.*; public class hellojava { public static void main(String[] args) { Scanner input new Scanner(System…

mySQL教程 第9章 觸發器

第9章 觸發器 入的新數據放到new表&#xff0c;刪除的數據放到old表。 準備本章學習環境 連接數據庫schoolDB&#xff0c;刪除表TStudent&#xff0c;TScore和Tsubject中的所有數據。 delete from TStudent; delete from TScore; delete from TSubject; 向學生表插入兩條記錄 i…

vue使用python_如何使用Python和Vue創建兩人游戲

vue使用pythonby Neo Ighodaro由新Ighodaro 如何使用Python和Vue創建兩人游戲 (How to create a two-player game with Python and Vue) In this tutorial, we will create a realtime tic-tac-toe game using Python and Pusher channels. Here’s a demo of how the game wi…

掩碼圖制作photoshop__新手用

1.首先你得有一張圖&#xff0c;比如這樣的&#xff1a; 2.用PS打開他 3.左邊工具欄里&#xff08;快速選擇工具W&#xff09;&#xff0c;選想顯示的部分 4.ctrlc復制一下&#xff0c;新建一張黑底圖粘貼上去或者白底圖時選中顯示區即花瓣右鍵反向右鍵填充成黑色 5.菜單欄->…