Questions tagged «shell»

Shell是Unix的命令行界面。您可以交互地在外壳程序中键入命令,也可以编写脚本来自动执行任务。使用此标记可解决适用于/ bin / sh和大多数兼容shell(ash,bash,ksh,zsh等)的问题。对于有错误的Shell脚本,请在此处发布之前在http://shellcheck.net中对其进行检查。


1
我可以按月分组吗?
我的目录中有很多照片。具体来说,du -sh --apparent-size /path/to/myfolder给我331G。太好了 但是现在我想要按月分组的列表,例如: 2016-01 20MB 2016-02 520MB 2016-03 312MB ... 是否有(合理的)方式使用linux内置函数来执行此操作,还是我应该编写自己的Python实用程序来执行此操作?



2
使用`find -exec`有哪些安全问题和竞争条件?
从find手册页: -exec command ; There are unavoidable security problems surrounding use of the -exec action; you should use the -execdir option instead. -execdir command {} + Like -exec, but the specified command is run from the subdirectory containing the matched file, which is not normally the directory in which you …
14 shell  find  security 

5
如何找到长路径中第一个丢失的目录?
想象一下,我有一条不存在的路径: $ ls /foo/bar/baz/hello/world ls: cannot access /foo/bar/baz/hello/world: No such file or directory 但是,说/foo/bar 确实存在。有没有一种快速的方法可以让我确定baz路径的起点? 我正在使用Bash。
14 bash  shell  directory  ls 

2
是否有非交互式登录外壳?
我知道交互式/非交互式外壳程序和登录/非登录外壳程序之间有什么区别,但是在实践中似乎永远不会有非交互式登录外壳程序,除非您/bin/bash --login some-script.sh在脚本中有类似的东西(甚至看起来有点奇怪)。这是正确的还是更常见?
14 shell 

8
检查变量是像Bourne这样的shell中的数组吗?
在像shell这样的Bourne中,它支持数组变量,我们可以使用一些解析来检查变量是否为数组。 下面的所有命令都在运行后运行a=(1 2 3)。 zsh: $ declare -p a typeset -a a a=( 1 2 3 ) bash: $ declare -p a declare -a a='([0]="1" [1]="2" [2]="3")' ksh93: $ typeset -p a typeset -a a=(1 2 3) pdksh 及其派生词: $ typeset -p a set -A a typeset a[0]=1 typeset a[1]=2 …
14 bash  shell  zsh  ksh  yash 

3
'find -exec'如何传递带有空格的文件名?
如果我的目录包含一些名称带有空格的文件,例如 $ ls -1 dir1 file 1 file 2 file 3 我可以将它们全部成功复制到另一个目录,如下所示: $ find dir1 -mindepth 1 -exec cp -t dir2 {} + 但是,的输出find dir1 -mindepth 1包含未转义的空格: $ find dir1 mindepth 1 dir1/file 1 dir1/file 3 dir1/file 3 如果我使用print0而不是print,则输出仍包含未转义的空格: $ find dir1 mindepth 1 -print0 dir1/file 1dir1/file 2dir1/file 3 要使用手动复制这些文件cp,我需要转义空格;但是,似乎当cp的参数来自时,这是不必要的find,而不管我是使用命令+还是\;命令的末尾。 …

9
如何链接命令“ date -d @xxxxxx”和“ find ./”?
我有名称为时间戳的目录,自1970-01-01起以毫秒为单位: 1439715011728 1439793321429 1439879712214 . . 我需要这样的输出: 1442039711 Sat Sep 12 08:35:11 CEST 2015 1442134211 Sun Sep 13 10:50:11 CEST 2015 1442212521 Mon Sep 14 08:35:21 CEST 2015 . . 我可以通过命令列出所有目录: find ./ -type d | cut -c 3-12 但是我不能将输出放到下一个命令:date -d @xxxxxx并操纵输出。 我怎样才能做到这一点?
14 shell  find  date 


3
准备命令问题的答案
假设我想编写一个仅执行一个命令的shell脚本。但是此命令的设计不当。它不提供任何命令行选项。相反,它会问一些问题并等待用户输入。 有没有办法在脚本中准备此输入,因此问题会自动得到回答?

4
echo $ -1显示什么?
什么是输出echo $-1,echo $-2,echo $-3..是什么意思? 在我的一个Linux机器上,它显示了我: echo $-1 imsBEl1 echo $-2 imsBEl2 在另一个Linux机器上,它显示: echo $-1 himBH1 echo $-2 himBH2 它们是映射到某些内存位置还是其他东西?
14 shell  echo  parameter 

2
是否存在知道Markdown的拼写检查器?
在发布文章之前,我想对文章进行拼写检查。我认为aspell还可以,但它不应尝试检查代码块: asdfasdfa adsfa sdfa text to check adsfasd f ``` a wild code block appeared! thisHas quiteOften() some strings.that should NOT get changed ``` and also `inlined code` should not get checked Linux是否存在基于命令行的拼写检查器,它们知道Markdown并因此忽略代码块?我需要能够以批处理模式运行多个文件。 (如果您知道一个真正了解LaTeX的人,aspell -t则可获得加分-不,不能完全正常工作)


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.