有一个设计:
read -p "Are you sure? "
可以添加一个默认响应,最终它看起来像这样:
你确定吗?是的
在这种情况下,用户只需按回车键
你能告诉我如何使用单线解决以下问题吗?
目标是从当前行的第一列中减去前一行的第一列的值,并将其放在当前行之前。
有一个文件,如:
$ cat blabla
13:06:27.578195 blablabla
13:06:27.578243 bla bla
13:06:27.578271 bla
13:06:27.578337 zzz
13:06:27.578372 zzz zzz zzz
13:06:27.578372 zzz zzz zzz
13:07:02.224100 aaa bbb ccc
有必要在一行中使用任何命令来获取表单的输出:
0 13:06:27.578195 blablabla
0.000048 13:06:27.578243 bla bla
0.000028 13:06:27.578271 bla
0.000066 13:06:27.578337 zzz
0.000035 13:06:27.578372 zzz zzz zzz
34,645728 13:07:02.224100 aaa bbb ccc
似乎这可以用 来完成awk
,但我没有成功。
我正在编写一个脚本,从所有给定掩码的文件中确定文件的最后一行是否是“不正确的卷”
#!/bin/sh
f=`find -name \*-volume.log`
for file in $f
do
out = `tail -n 1 ${file#*./}`
echo $out
if [$out = "Incorrect volume" ]
then
echo "Privet"
fi
echo ${file#*./}
done
我写了这段代码,但由于某种原因它没有读取 out 变量,也不接受字符串比较条件。帮助理解错误。
脚本“wget_test.R”:
print(paste0('OUT:', shell("bash -c 'wget https://www.ft.com -O out.html'", intern = TRUE)))
我在 R 控制台中运行:
[1] "OUT:Will not apply HSTS. The HSTS database must be a regular and non-world-writable file."
[2] "OUT:ERROR: could not open HSTS store at '/home/adollo/.wget-hsts'. HSTS will be disabled."
[3] "OUT:--2019-07-18 14:58:46-- https://www.ft.com/"
[4] "OUT:Resolving www.ft.com (www.ft.com)... 151.101.246.109"
[5] "OUT:Connecting to www.ft.com (www.ft.com)|151.101.246.109|:443... connected."
[6] "OUT:HTTP request sent, awaiting response... 200 OK"
[7] "OUT:Length: 446829 (436K) [text/html]"
[8] "OUT:Saving to: вЂ\u0098out.html’"
[9] "OUT:"
[10] "OUT: 0K .......... .......... .......... .......... .......... 11% 851K 0s"
[11] "OUT: 50K .......... .......... .......... .......... .......... 22% 1.65M 0s"
[12] "OUT: 100K .......... .......... .......... .......... .......... 34% 47.7M 0s"
[13] "OUT: 150K .......... .......... .......... .......... .......... 45% 51.5M 0s"
[14] "OUT: 200K .......... .......... .......... .......... .......... 57% 636K 0s"
[15] "OUT: 250K .......... .......... .......... .......... .......... 68% 36.9M 0s"
[16] "OUT: 300K .......... .......... .......... .......... .......... 80% 47.7M 0s"
[17] "OUT: 350K .......... .......... .......... .......... .......... 91% 51.0M 0s"
[18] "OUT: 400K .......... .......... .......... ...... 100% 47.2M=0.2s"
[19] "OUT:"
[20] "OUT:2019-07-18 14:58:46 (2.46 MB/s) - вЂ\u0098out.html’ saved [446829/446829]"
[21] "OUT:"
我在 Windows 终端中运行“RScript wget_test.R”:
Will not apply HSTS. The HSTS database must be a regular and non-world-writable file.
ERROR: could not open HSTS store at '/home/adollo/.wget-hsts'. HSTS will be disabled.
--2019-07-18 14:59:03-- https://www.ft.com/
Resolving www.ft.com (www.ft.com)... 151.101.246.109
Connecting to www.ft.com (www.ft.com)|151.101.246.109|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 446759 (436K) [text/html]
Saving to: ‘out.html’
out.html 100%[=================================================>] 436.29K --.-KB/s in 0.1s
2019-07-18 14:59:03 (3.07 MB/s) - ‘out.html’ saved [446759/446759]
[1] "OUT:"
我也试过系统功能 - 结果是一样的。
结果差异的原因可能是什么?
R 控制台中的 sessionInfo():
R version 3.6.0 (2019-04-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)
Matrix products: default
locale:
[1] LC_COLLATE=Russian_Russia.1251 LC_CTYPE=Russian_Russia.1251 LC_MONETARY=Russian_Russia.1251 LC_NUMERIC=C
[5] LC_TIME=Russian_Russia.1251
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rvest_0.3.4 xml2_1.2.0
loaded via a namespace (and not attached):
[1] httr_1.4.0 compiler_3.6.0 selectr_0.4-1 magrittr_1.5 R6_2.4.0 tools_3.6.0 curl_3.3 Rcpp_1.0.1 stringi_1.4.3
[10] stringr_1.4.0
sessionInfo() 通过 RScript.exe:
R version 3.6.0 (2019-04-26) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 18362)
Matrix products: default
locale: [1] LC_COLLATE=Russian_Russia.1251 LC_CTYPE=Russian_Russia.1251 [3] LC_MONETARY=Russian_Russia.1251 LC_NUMERIC=C [5] LC_TIME=Russian_Russia.1251
attached base packages: [1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached): [1] compiler_3.6.0
您需要运行控制台命令来获取文件大小:
hadoop fs -du some/path
并将结果存储在变量中。如何在 Scala 中做到这一点?