Linux终端头命令问题
我刚刚开始学习Linux终端的基础知识,我遇到了一些问题。我想使用curl或wget下载一个文件并显示其内容,但当我输入head命令时,它会给我html脚本,而不是实际的csv内容。这是我的密码:Linux终端头命令问题,linux,csv,ssh,terminal,command-line-interface,Linux,Csv,Ssh,Terminal,Command Line Interface,我刚刚开始学习Linux终端的基础知识,我遇到了一些问题。我想使用curl或wget下载一个文件并显示其内容,但当我输入head命令时,它会给我html脚本,而不是实际的csv内容。这是我的密码: curl -O http://files.grouplens.org/datasets/movielens/ml-latest-small.zip unzip ml-latest-small.zip head -n 12 movies.csv 以下是返回的内容: <!DOCTYPE html&
curl -O http://files.grouplens.org/datasets/movielens/ml-latest-small.zip
unzip ml-latest-small.zip
head -n 12 movies.csv
以下是返回的内容:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="dns-prefetch" href="https://github.githubassets.com">
<link rel="dns-prefetch" href="https://avatars0.githubusercontent.com">
<link rel="dns-prefetch" href="https://avatars1.githubusercontent.com">
有人知道我做错了什么吗?好吧——这当然很奇怪——我只是毫无错误地运行了确切的命令
您是否将CD刻录到新创建的解压缩文件夹中
pi@raspberrypi:~ $ curl -O http://files.grouplens.org/datasets/movielens/ml-latest-small.zip
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 955k 100 955k 0 0 942k 0 0:00:01 0:00:01 --:--:-- 943k
pi@raspberrypi:~ $ unzip ml-latest-small.zip
Archive: ml-latest-small.zip
creating: ml-latest-small/
inflating: ml-latest-small/links.csv
inflating: ml-latest-small/tags.csv
inflating: ml-latest-small/ratings.csv
inflating: ml-latest-small/README.txt
inflating: ml-latest-small/movies.csv
pi@raspberrypi:~ $ cd ml-latest-small/
pi@raspberrypi:~/ml-latest-small $ ls
links.csv movies.csv ratings.csv README.txt tags.csv
pi@raspberrypi:~/ml-latest-small $ head -n 12 movies.csv
movieId,title,genres
1,Toy Story (1995),Adventure|Animation|Children|Comedy|Fantasy
2,Jumanji (1995),Adventure|Children|Fantasy
3,Grumpier Old Men (1995),Comedy|Romance
4,Waiting to Exhale (1995),Comedy|Drama|Romance
5,Father of the Bride Part II (1995),Comedy
6,Heat (1995),Action|Crime|Thriller
7,Sabrina (1995),Comedy|Romance
8,Tom and Huck (1995),Adventure|Children
9,Sudden Death (1995),Action
10,GoldenEye (1995),Action|Adventure|Thriller
11,"American President, The (1995)",Comedy|Drama|Romance
有点不对劲。如果这些是您实际运行的命令,并且它们都成功了,那么您下载的文件根本不包含您期望的内容。现在还不清楚为什么从zip文件中提取的CSV文件会包含HTML。此外,这可能更适合于unix.stackexchange.com,因为它更多地处理一些命令行程序的使用,而不是脚本编写。用于编程问题,而不是有关使用或配置Unix及其实用程序的问题。或者是回答类似问题的好地方。大概对OP来说不太明显。起初我没有将CD刻录到新文件中,但我只是这样做了,而且成功了。谢谢。太棒了:)还有-你的命令真的很有用!只运行head-n/ml最新的small/12 movies.csv可能更容易,这样您就不必每次都将CD刻录到其中
pi@raspberrypi:~ $ curl -O http://files.grouplens.org/datasets/movielens/ml-latest-small.zip
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 955k 100 955k 0 0 942k 0 0:00:01 0:00:01 --:--:-- 943k
pi@raspberrypi:~ $ unzip ml-latest-small.zip
Archive: ml-latest-small.zip
creating: ml-latest-small/
inflating: ml-latest-small/links.csv
inflating: ml-latest-small/tags.csv
inflating: ml-latest-small/ratings.csv
inflating: ml-latest-small/README.txt
inflating: ml-latest-small/movies.csv
pi@raspberrypi:~ $ cd ml-latest-small/
pi@raspberrypi:~/ml-latest-small $ ls
links.csv movies.csv ratings.csv README.txt tags.csv
pi@raspberrypi:~/ml-latest-small $ head -n 12 movies.csv
movieId,title,genres
1,Toy Story (1995),Adventure|Animation|Children|Comedy|Fantasy
2,Jumanji (1995),Adventure|Children|Fantasy
3,Grumpier Old Men (1995),Comedy|Romance
4,Waiting to Exhale (1995),Comedy|Drama|Romance
5,Father of the Bride Part II (1995),Comedy
6,Heat (1995),Action|Crime|Thriller
7,Sabrina (1995),Comedy|Romance
8,Tom and Huck (1995),Adventure|Children
9,Sudden Death (1995),Action
10,GoldenEye (1995),Action|Adventure|Thriller
11,"American President, The (1995)",Comedy|Drama|Romance