【发布时间】:2021-01-11 21:23:53
【问题描述】:
我刚刚开始学习 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
有谁知道我做错了什么?
【问题讨论】:
-
有些不对劲。如果这些是您运行的实际命令并且它们都成功了,那么您下载的文件根本不包含您的预期。完全不清楚为什么从 zip 文件中提取的 CSV 文件会包含 HTML。
-
另外,这可能更适合 unix.stackexchange.com,因为它更多地处理一些命令行程序的使用而不是脚本。
-
Stack Overflow 用于编程问题,而不是关于使用或配置 Unix 及其实用程序的问题。 Unix & Linux 或 Super User 将是解决此类问题的更好地方。
标签: linux csv ssh terminal command-line-interface