如何解决Linux Terminal Head命令问题
我刚刚开始学习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>
<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">
但这是我想要的输出:
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
有人知道我在做什么吗?
解决方法
好吧-确实很奇怪-我只运行了准确的命令而没有错误。
您是否将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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。