mac终端刷新数据库数据_数据科学家终端

mac终端刷新数据库数据

Introduction

介绍

If you are have not been using the command-line tool yet, it is time to start.

如果您尚未使用命令行工具,那么该开始了。

This article presents the first commands to get you started on this journey.

本文介绍了帮助您入门的第一个命令。

You will learn how to navigate through folders and files, and modify them without opening any editing software or using a graphical user interface.

您将学习如何浏览文件夹和文件,以及如何在不打开任何编辑软件或不使用图形用户界面的情况下对其进行修改。

This will make you a more productive and better Data Scientist.

这将使您成为生产力更高,更好的数据科学家。

Lunch your terminal window

在您的终端窗口中午餐

Image for post

As you can see I keep my terminal handy in Dock of my Mac, so I can lunch it from there.

如您所见,我将终端机放在Mac的Dock中,因此可以从那里享用午餐。

Once the application is open you should see the Terminal window similar to the one below. It should open in the current userspace. My user here is called ‘konki’.

打开应用程序后,您将看到类似于以下窗口的“终端”窗口。 它应该在当前用户空间中打开。 我的用户在这里称为“ konki”。

Image for post

This is the window where you will be typing your commands!!!

这是您将在其中键入命令的窗口!!!

***Note that the commands I will be showing here are valid for MacOS and other Unix operating systems. If you are using Windows Command Prompt most of these commands should work but other ones may need some alternation.

***请注意,我将在此处显示的命令对MacOS和其他Unix操作系统有效。 如果您使用的是Windows命令提示符,则这些命令中的大多数命令应该可以使用,但其他命令可能需要进行一些替换。

  1. pwd (print working directory)

    pwd(打印工作目录)

The first command will show you the current directory that you are in. Just type ‘pwd’ as shown below:

第一个命令将显示您当前所在的目录。只需键入“ pwd”,如下所示:

konkis-MacBook-Air:~ konki$ pwd
/Users/konki

You can see that I am now in ‘/Users/konki’ directory.

您可以看到我现在位于“ / Users / konki”目录中。

2. ls (list)

2. ls(清单)

This command list all files in a directory. Let’s have a look.

此命令列出目录中的所有文件。 我们来看一下。

konkis-MacBook-Air:~ konki$ ls
Applications Downloads Music cd
Desktop Library Pictures seaborn-data
Documents Movies Public

You can see I have eleven directories and no files (if I had some files you would see names with some extensions. e.g .txt. or .py)

您可以看到我有11个目录,没有文件(如果我有一些文件,您会看到带有某些扩展名的名称,例如.txt或.py)

You can use ls with -a parameter to show hidden files:

您可以将ls与-a参数一起使用以显示隐藏文件:

konkis-MacBook-Air:~ konki$ ls -a
. .ipython Downloads
.. .jupyter Library
.CFUserTextEncoding .matplotlib Movies
.DS_Store .pgAdmin4.startup.log Music
.Trash .pgadmin Pictures
.astropy Applications Public
.bash_history Desktop cd
.bash_sessions Documents seaborn-data

It looks like I have quite a lot of hidden files. Those are the ones starting with a dot (.).

看来我有很多隐藏文件。 这些是以点(。)开头的。

You can also inspect the content of the folder that you are not currently in by passing its relative path.

您还可以通过传递其相对路径来检查当前不在的文件夹的内容。

ls Desktop/

The command above should list the contents of the Desktop directory.

上面的命令应列出Desktop目录的内容。

3. mkdir ( make directory)

3. mkdir( make目录)

This command is used to create a new directory. The following line of code creates a new directory in the current folder named test.

此命令用于创建新目录。 下面的代码行在当前文件夹test中创建一个新目录。

konkis-MacBook-Air:~ konki$ mkdir test

You can use ‘ls’ command to check if this has been created.

您可以使用“ ls”命令检查是否已创建。

4. cd (change directory)

4. cd(更改目录)

This command is used to change directory to the one with the path given. Once you have created ‘test’ directory you should be able to enter into it.

此命令用于将目录更改为具有给定路径的目录。 创建“测试”目录后,您应该可以进入该目录。

konkis-MacBook-Air:~ konki$ cd test/
konkis-MacBook-Air:test konki$ pwd
/Users/konki/test

You can confirm where you are by using ‘pwd’ command as above.

您可以使用上面的“ pwd”命令来确认您的位置。

Other useful variations of ‘cd’ command are ‘cd’ (without an argument) and ‘cd~’ . They will both take you to the home directory.

'cd'命令的其他有用变体是'cd'(不带参数)和'cd〜'。 他们俩都会带您到主目录。

cd
cd~

Also, the common use of ‘cd’ is to return to the parent directory that can be done with two dots.

同样,“ cd”的常用用法是返回到父目录,该目录可以用两个点完成。

cd ..

5. touch

5.触摸

You can use this to create a new file. The code below creates my_file.py. and then uses ‘ls’ command to check the content of the directory.

您可以使用它来创建一个新文件。 下面的代码创建my_file.py。 然后使用“ ls”命令检查目录的内容。

konkis-MacBook-Air:test konki$ touch my_file.py
konkis-MacBook-Air:test konki$ ls
my_file.py

The file we have created is just an empty file with .py extension. We could add some python code there later on.

我们创建的文件只是一个扩展名为.py的空文件。 稍后我们可以在其中添加一些python代码。

6. rm (remove)

6. rm(删除)

We can remove files or directories with the remove command. With the file, it is enough to call this command with the filename as shown below.

我们可以使用remove命令删除文件或目录。 使用该文件,只需使用文件名调用此命令即可,如下所示。

konkis-MacBook-Air:test konki$ rm my_file.py 
konkis-MacBook-Air:test konki$ ls
konkis-MacBook-Air:test konki$

You can always confirm if the file was removed with the ‘ls’ command as above.

您始终可以通过上述“ ls”命令确认是否删除了文件。

If you want to remove a whole directory you would have to add -r parameter. This would make remove command to work recursively and enter all subdirectories to delete their content as well.

如果要删除整个目录,则必须添加-r参数。 这将使remove命令以递归方式工作,并输入所有子目录以删除其内容。

rm -r <directory_name>

7. mv (move)

7. mv(移动)

You can move files and directories around with the command ‘mv’. You just need to specify a file or folder name you want to move and the new desired location (folder or filename).

您可以使用命令“ mv”来移动文件和目录。 您只需要指定要移动的文件或文件夹名称以及新的所需位置(文件夹或文件名)即可。

mv <file_name> <new_location>

Let’s create a new file and move it to the parent directory.

让我们创建一个新文件并将其移动到父目录。

konkis-MacBook-Air:Downloads konki$ touch file.txt
konkis-MacBook-Air:Downloads konki$ mv file.txt ..

The last line moves the file.txt to the parent directory. Remember, two dots(..) are the shortcut for the parent directory.

最后一行将file.txt移动到父目录。 请记住,两个点(..)是父目录的快捷方式。

8. cp (copy)

8. cp(复制)

You can also copy files and folders instead of moving them. The structure of the command is similar to move command. You need to specify the file you want to copy and the destination.

您也可以复制文件和文件夹,而不用移动它们。 命令的结构类似于移动命令。 您需要指定要复制的文件和目的地。

cp <file_name> <new_location>

Let’s create a new file and copy it to the parent directory.

让我们创建一个新文件并将其复制到父目录。

konkis-MacBook-Air:Downloads konki$ touch file_to_copy.txt
konkis-MacBook-Air:Downloads konki$ cp file_to_copy.txt ..

Now if you use ‘ls’ command you will see that the file is still in its original location.

现在,如果使用“ ls”命令,您将看到该文件仍位于其原始位置。

If you go back to the parent folder with ‘cd ..’ and use ‘ls’ again you will see that ‘file_to_copy.txt’ is there as well. It got copied over there without deleting the original file.

如果使用“ cd ..”返回到父文件夹并再次使用“ ls”,您还将看到“ file_to_copy.txt”也在那里。 它被复制到那里,而没有删除原始文件。

9. man (manual)

9.男人(手动)

This command is useful when you forgot how to use any of the commands presented above. It pulls up a manual for a particular command.

当您忘记了如何使用上面介绍的任何命令时,此命令很有用。 它为特定命令编写了手册。

man <command>

You can test in on ‘pwd’ command.

您可以在“ pwd”命令中进行测试。

man pwd

This should open a description of the ‘pwd’ command as shown on the screenshot below.

这将打开“ pwd”命令的描述,如下面的屏幕快照所示。

Image for post

You can scroll down with the arrow to access the text on the bottom and type ‘q’ to exit the text file.

您可以向下滚动箭头以访问底部的文本,然后键入“ q”退出文本文件。

Summary

摘要

I think this is a list of commands that I most often use while navigating my Macbook and working on projects. It saves me a lot of time and effort in comparison to doing all of these using graphical user interfaces.

我认为这是在Macbook导航和项目开发中最常用的命令列表。 与使用图形用户界面进行所有这些操作相比,它节省了很多时间和精力。

Start with learning those nine and work towards using the command line on an everyday basis.

首先学习这九个,然后每天努力使用命令行。

Originally published at https://www.aboutdatablog.com on August 26, 2020.

最初于 2020年8月26日 发布在 https://www.aboutdatablog.com

PS: I am writing articles that explain basic Data Science concepts in a simple and comprehensible on aboutdatablog.com. If you liked this article there are some other ones you may enjoy:

PS:我写的文章在 aboutdatablog.com 上以简单易懂的方式解释了基本的数据科学概念如果您喜欢这篇文章,您可能还会喜欢其他一些文章:

翻译自: https://towardsdatascience.com/terminal-for-data-scientists-3615159e936c

mac终端刷新数据库数据

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值