日韩成人免费在线_国产成人一二_精品国产免费人成电影在线观..._日本一区二区三区久久久久久久久不

當前位置:首頁 > 科技  > 軟件

17個有用的CLI命令,作為前端工程師,你需要知道一下

來源: 責編: 時間:2024-01-02 09:31:58 257觀看
導讀作為前端開發工程師,我們需要了解哪些命令?如果您熟悉這些命令,它們將大大提高您的工作效率。1. tree小伙伴們,你們知道如何列出一個目錄的文件結構嗎?它在顯示文件之間的目錄關系方面做得很好,這真的很酷。commands├──

作為前端開發工程師,我們需要了解哪些命令?如果您熟悉這些命令,它們將大大提高您的工作效率。BQD28資訊網——每日最新資訊28at.com

BQD28資訊網——每日最新資訊28at.com

1. tree

小伙伴們,你們知道如何列出一個目錄的文件結構嗎?BQD28資訊網——每日最新資訊28at.com

它在顯示文件之間的目錄關系方面做得很好,這真的很酷。BQD28資訊網——每日最新資訊28at.com

commands├── a.js├── b.js├── c.js├── copy-apps│   └── fe-apps│       └── a.js├── fe-apps│   └── a.js├── test.log└── xxx    └── yyy

在此之前,您需要安裝命令樹。BQD28資訊網——每日最新資訊28at.com

brew install tree

然后只需在文件目錄中執行tree即可。BQD28資訊網——每日最新資訊28at.com

BQD28資訊網——每日最新資訊28at.com

2.wc

wc 是 word count 的縮寫,常用于文件統計。它可以統計字數、行數、字符數、字節數等。BQD28資訊網——每日最新資訊28at.com

我經常用它來計算文件中的代碼行數。BQD28資訊網——每日最新資訊28at.com

BQD28資訊網——每日最新資訊28at.com

3.du

打印出一個目錄的文件大小信息。我們使用它的頻率較低,但它是一個非常值得學習的命令。BQD28資訊網——每日最新資訊28at.com

  • du -h:打印出適合人類閱讀的信息。
  • du -a:列出目錄中文件大小的信息;
  • du -s:只顯示總大小,不顯示具體信息。
?  commands git:(master) ? du0  ./xxx/yyy0  ./xxx0  ./fe-apps0  ./copy-apps/fe-apps0  ./copy-apps0  ./.git/objects/pack0  ./.git/objects/info0  ./.git/objects8  ./.git/info104  ./.git/hooks0  ./.git/refs/heads0  ./.git/refs/tags0  ./.git/refs136  ./.git168  .
?  commands git:(master) ? du -h  0B  ./xxx/yyy  0B  ./xxx  0B  ./fe-apps  0B  ./copy-apps/fe-apps  0B  ./copy-apps  0B  ./.git/objects/pack  0B  ./.git/objects/info  0B  ./.git/objects4.0K  ./.git/info 52K  ./.git/hooks  0B  ./.git/refs/heads  0B  ./.git/refs/tags  0B  ./.git/refs 68K  ./.git 84K  .

BQD28資訊網——每日最新資訊28at.com

?  commands git:(master) ? du -ha4.0K  ./a.js  0B  ./xxx/yyy  0B  ./xxx  0B  ./fe-apps/a.js  0B  ./fe-apps4.0K  ./test.log  0B  ./copy-apps/fe-apps/a.js  0B  ./copy-apps/fe-apps  0B  ./copy-apps4.0K  ./c.js4.0K  ./.git/config  0B  ./.git/objects/pack  0B  ./.git/objects/info  0B  ./.git/objects4.0K  ./.git/HEAD4.0K  ./.git/info/exclude4.0K  ./.git/info4.0K  ./.git/description4.0K  ./.git/hooks/commit-msg.sample8.0K  ./.git/hooks/pre-rebase.sample4.0K  ./.git/hooks/pre-commit.sample4.0K  ./.git/hooks/applypatch-msg.sample4.0K  ./.git/hooks/fsmonitor-watchman.sample4.0K  ./.git/hooks/pre-receive.sample4.0K  ./.git/hooks/prepare-commit-msg.sample4.0K  ./.git/hooks/post-update.sample4.0K  ./.git/hooks/pre-merge-commit.sample4.0K  ./.git/hooks/pre-applypatch.sample4.0K  ./.git/hooks/pre-push.sample4.0K  ./.git/hooks/update.sample 52K  ./.git/hooks  0B  ./.git/refs/heads  0B  ./.git/refs/tags  0B  ./.git/refs 68K  ./.git4.0K  ./b.js 84K  .

BQD28資訊網——每日最新資訊28at.com

du -sh

BQD28資訊網——每日最新資訊28at.com

4. alias

alias命令用于設置命令的別名。如果您僅鍵入別名,將列出所有當前別名設置。BQD28資訊網——每日最新資訊28at.com

BQD28資訊網——每日最新資訊28at.com

讓我們嘗試為 git status 設置一個別名BQD28資訊網——每日最新資訊28at.com

alias gs="git status"

BQD28資訊網——每日最新資訊28at.com

值得注意的是:如果你想讓gs命令永久存在,你應該在.profile或.zshrc中設置它。BQD28資訊網——每日最新資訊28at.com

5.grep

我們經常需要查找服務器上日志文件的內容,grep將是我們得心應手的幫手。BQD28資訊網——每日最新資訊28at.com

有一個日志文件test.log。它包含以下內容:BQD28資訊網——每日最新資訊28at.com

const a = 1const b = 2const c = 3
console.log(a + b + c)

如何突出顯示包含 a 字符的位置?這很容易,不是嗎?BQD28資訊網——每日最新資訊28at.com

grep a test.log

BQD28資訊網——每日最新資訊28at.com

6.cat

cat 的主要用途是查看文件的內容并將其打印在屏幕上。BQD28資訊網——每日最新資訊28at.com

但它至少還有一些其他用途。BQD28資訊網——每日最新資訊28at.com

1.清除a.js的內容BQD28資訊網——每日最新資訊28at.com

?  commands git:(master) ? cat a.js // There are two lines of code in a.jsconst a = 'fatfish'
console.log(a)%?  commands git:(master) ? cat /dev/null > a.js // clear the contents of a.js?  commands git:(master) ? cat a.js // The content in a.js is cleared.?  commands git:(master) ?

BQD28資訊網——每日最新資訊28at.com

2.將a.js的內容復制到b.js

?  commands git:(master) ? cat a.jsconst name = 'fatfish'console.log(name)?  commands git:(master) ? cat b.js // No content in b.js?  commands git:(master) ? cat a.js > b.js // Copy the contents of a.js to b.js?  commands git:(master) ? cat b.js // The content in b.js is the same as in a.jsconst name = 'fatfish'console.log(name)?  commands git:(master) ? cat a.jsconst name = 'fatfish'console.log(name)

BQD28資訊網——每日最新資訊28at.com

3.將a.js的內容添加到c.js的最后一個字符BQD28資訊網——每日最新資訊28at.com

?  commands git:(master) ? cat a.jsconst name = 'fatfish'console.log(name)%?  commands git:(master) ? cat c.jsconst age = 100console.log(age)?  commands git:(master) ? cat a.js >> c.js?  commands git:(master) ? cat c.jsconst age = 100console.log(age)const name = 'fatfish'console.log(name)

BQD28資訊網——每日最新資訊28at.com

7.clear

有時候,我們需要在終端中進行一些操作,這樣屏幕上的內容就足以讓我們感到煩惱了。BQD28資訊網——每日最新資訊28at.com

如何清除它們?我們需要逐行刪除它們嗎?BQD28資訊網——每日最新資訊28at.com

BQD28資訊網——每日最新資訊28at.com

8.cp

cp命令用于復制文件或目錄。BQD28資訊網——每日最新資訊28at.com

cp -f:當要復制的文件覆蓋已有的目標文件時,不會有提示信息。BQD28資訊網——每日最新資訊28at.com

cp -r:如果復制的文件是目錄文件,則復制該目錄下的所有子目錄和文件。BQD28資訊網——每日最新資訊28at.com

?  commands git:(master) ? ls -Ra.js      b.js      copy-apps fe-apps./copy-apps:./fe-apps:// 1. copy a file?  commands git:(master) ? cp a.js fe-apps?  commands git:(master) ? ls -Ra.js      b.js      copy-apps fe-apps./copy-apps:./fe-apps:a.js?  commands git:(master) ? cp fe-apps copy-appscp: fe-apps is a directory (not copied).// 2. copy a directory?  commands git:(master) ? cp -rf fe-apps copy-apps?  commands git:(master) ? ls -Ra.js      b.js      copy-apps fe-apps./copy-apps:fe-apps./copy-apps/fe-apps:a.js./fe-apps:a.js

BQD28資訊網——每日最新資訊28at.com

9.cd

這篇文章肯定沒什么技術性,因為關于 cd 真的沒什么可寫的,作為一個開發者,誰不熟悉它呢?BQD28資訊網——每日最新資訊28at.com

也許你是對的,但我只是想說 cd - 可以返回到你上次訪問的目錄。我認為這是一個好技巧。BQD28資訊網——每日最新資訊28at.com

BQD28資訊網——每日最新資訊28at.com

10. ls

這是一個非常常用的命令,它用于顯示文件目錄的內容列表。BQD28資訊網——每日最新資訊28at.com

它至少可以通過 3 種方式使用。BQD28資訊網——每日最新資訊28at.com

  • ls -a:顯示所有文件和目錄(包括以.目錄開頭的)
  • ls -A:顯示所有文件和目錄(不包括以.directory開頭的目錄)
  • ls -R:顯示所有文件和目錄,如果目錄中有文件,則按順序列出

BQD28資訊網——每日最新資訊28at.com

11.rm

它用于刪除文件或目錄。BQD28資訊網——每日最新資訊28at.com

rm -i:將目錄下的文件逐個刪除,刪除前會詢問是否刪除該文件。BQD28資訊網——每日最新資訊28at.com

BQD28資訊網——每日最新資訊28at.com

rm -r:一起處理指定目錄及其子目錄下的所有文件(注:不刪除文件。)BQD28資訊網——每日最新資訊28at.com

rm -f:用于強制刪除文件或目錄。BQD28資訊網——每日最新資訊28at.com

BQD28資訊網——每日最新資訊28at.com

12.tail

我想你一定也有在服務器上查看日志內容的經歷,tail絕對是一個好幫手。BQD28資訊網——每日最新資訊28at.com

tail -f filename 會將 filename 尾部的內容顯示在屏幕上,當其內容發生變化時,您將在屏幕上看到最新的內容。BQD28資訊網——每日最新資訊28at.com

BQD28資訊網——每日最新資訊28at.com

13.MV

有時我們想要更改一個文件或目錄的名稱,或者將其移動到另一個地方,那么我們可以使用 mv 命令。BQD28資訊網——每日最新資訊28at.com

1.修改文件名BQD28資訊網——每日最新資訊28at.com

?  commands git:(master) ? lsa.js?  commands git:(master) ? mv a.js xxx.js?  commands git:(master) ? lsxxx.js?  commands git:(master) ?

BQD28資訊網——每日最新資訊28at.com

2. 將文件移動到其他目錄BQD28資訊網——每日最新資訊28at.com

?  commands git:(master) ? ls -Ra.js    fe-apps./fe-apps:xxx.js?  commands git:(master) ? mv a.js fe-apps?  commands git:(master) ? ls -Rfe-apps./fe-apps:a.js   xxx.js

BQD28資訊網——每日最新資訊28at.com

14.touch

我經常使用 touch 命令來創建新文件,盡管它是用來修改文件或目錄的時間屬性的。BQD28資訊網——每日最新資訊28at.com

BQD28資訊網——每日最新資訊28at.com

15.which

如果你想查看某個命令的具體路徑,可以使用which。BQD28資訊網——每日最新資訊28at.com

?  commands git:(master) ? which node/Users/dz0400229/.nvm/versions/node/v16.0.0/bin/node?  commands git:(master) ? which npm/Users/dz0400229/.nvm/versions/node/v16.0.0/bin/npm?  commands git:(master) ? which npx/Users/dz0400229/.nvm/versions/node/v16.0.0/bin/npx?  commands git:(master) ?

16.mkdir

是的,您以前肯定使用過這個命令,而且沒什么可說的!BQD28資訊網——每日最新資訊28at.com

但是mkdir -p dirname確實是我們很少使用的東西,它是用來做什么的呢?BQD28資訊網——每日最新資訊28at.com

?  commands git:(master) ? lsa.js      b.js      copy-apps fe-apps?  commands git:(master) ? mkdir xxx/yyy // You cannot create the yyy directory because the xxx directory does not existmkdir: xxx: No such file or directory?  commands git:(master) ? mkdir -p xxx/yyy // `-p` will check if the xxx directory already exists, and create it if it doesn't.?  commands git:(master) ? lsa.js      b.js      copy-apps fe-apps   xxx?  commands git:(master) ? ls -Ra.js      b.js      copy-apps fe-apps   xxx./copy-apps:fe-apps./copy-apps/fe-apps:a.js./fe-apps:a.js./xxx:yyy./xxx/yyy:

BQD28資訊網——每日最新資訊28at.com

17.whoami

顯示用戶名。BQD28資訊網——每日最新資訊28at.com

?  commands git:(master) ? whoamidz0400229

總結

以上就是我今天想與你分享的全部內容,如果你覺得有用的話,請記得點贊我,關注我,并將其文章分享給的朋友,也許能夠幫助到他。BQD28資訊網——每日最新資訊28at.com

本文鏈接:http://www.www897cc.com/showinfo-26-55349-0.html17個有用的CLI命令,作為前端工程師,你需要知道一下

聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。郵件:2376512515@qq.com

上一篇: 改bug更高效,手把手教你配置IntelliJ IDEA插件CheckStyle和Findbugs

下一篇: 深度揭秘JUnit5與Mockito的單元測試神秘面紗

標簽:
  • 熱門焦點
Top 主站蜘蛛池模板: 大冶市| 红原县| 新竹市| 安新县| 隆回县| 开平市| 大宁县| 白城市| 临朐县| 东安县| 文登市| 常熟市| 威宁| 中牟县| 台安县| 云梦县| 平潭县| 彰化市| 确山县| 兰坪| 屏边| 皮山县| 平遥县| 乌苏市| 彰化县| 都兰县| 紫云| 呼图壁县| 彭阳县| 六枝特区| 思茅市| 鹤壁市| 扎鲁特旗| 临湘市| 景宁| 类乌齐县| 宜宾市| 新丰县| 简阳市| 宣武区| 灵山县|