gpt4 book ai didi

bash - 如何在 Bash 脚本中运行 AWK?

转载 作者:行者123 更新时间:2023-11-29 09:38:51 25 4
gpt4 key购买 nike

问题与我的回答有关here .

我无法让下面的代码工作

#!/bin/bash 
wget http://www.google.com/coop/cse?cx=017685108214920485934%3Aizx6pzojwka -O CSE-spanien
awk '/^searches [1-9]* sites, including:/ { print $2 }' CSE-spanien

错误消息示例 [已编辑]

$./code
--2009-04-14 19:01:32-- http://www.google.com/coop/cse?cx=017685108214920485934%3Aizx6pzojwka
Resolving www.google.com... 74.125.79.103, 74.125.79.99, 74.125.79.147, ...
Connecting to www.google.com|74.125.79.103|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: `cse?cx=017685108214920485934:izx6pzojwka.6'

[ <=> ] 8,096 --.-K/s in 0s

2009-04-14 19:01:33 (78.0 MB/s) - `cse?cx=017685108214920485934:izx6pzojwka.6' saved [8096]

./code: line 3: -O: command not found
awk(57264) malloc: *** error for object 0x4eee0: Non-aligned pointer being freed (2)
*** set a breakpoint in malloc_error_break to debug
awk: cmd. line:1: fatal: cannot open file `/Users/Masi/Documents/test/CSE-spanien' for reading (No such file or directory)

如何在 Bash 脚本中运行 AWK?

最佳答案

您在 wget 行的末尾缺少 -O CSE-spanien。因此,CSE-spanien 不存在 - wget 将其保存为文件名为 cse?cx=017685108214920485934:izx6pzojwka.2.

关于bash - 如何在 Bash 脚本中运行 AWK?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/748185/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com