小编Abd*_*red的帖子

为什么 echo 命令不能与 at 命令一起使用?

当我输入:

at now + 1 min
at>play /usr/share/sounds/startrek.wav
at>ctrl+d
Run Code Online (Sandbox Code Playgroud)

它有效,所以一分钟后实际上播放了声音。

但是,当我输入:

at now + 1 min
at>echo "Teresa the green vegetable lover"
at>ctrl+d
Run Code Online (Sandbox Code Playgroud)

我没有收到来自 shell 的错误响应,但 1 分钟后也没有显示任何文本。

command-line at

14
推荐指数
1
解决办法
5499
查看次数

如何使用 find 命令从搜索中排除文件夹 proc 和 sys ?

我想执行一个脚本来挑选一个随机目录路径:

find / -type d | shuf -n1 
Run Code Online (Sandbox Code Playgroud)

不幸的是,我收到有关禁止进入某些目录的错误消息。

如何使用 find 从搜索中排除目录?

command-line find

14
推荐指数
2
解决办法
2万
查看次数

如何告诉 xargs 选择哪个参数?

当 xargs 将第一个命令输出重定向到第二个命令的参数并且无法选择输出的哪个元素的哪个参数时,那么只有一种方法,例如:

ls | xargs file  # there are as many arguments as files in the listing,
                 # but the user does not have too choose himself
Run Code Online (Sandbox Code Playgroud)

现在如果需要选择:

ls | xargs file | grep image | xargs mv.....   # here the user has to 
                                               # deal  with two arguments of mv, first for source second for destination, suppose your destination argument is set already by yourself and you have to put the output into the source argument. 
Run Code Online (Sandbox Code Playgroud)

您如何告诉 xargs …

command-line pipe xargs

14
推荐指数
1
解决办法
2万
查看次数

Linux 中是否有标准目录用于存储我的驱动程序文件?

我需要为声卡和显卡找到我的驱动程序,你知道如何找到它们的路径以及它们是否逻辑地存储在一个目录中吗?

drivers

13
推荐指数
1
解决办法
7万
查看次数

如何只显示列表的最后一行?

假设我列出并按其时间属性对文件进行排序:

ls -ltr

-rwxrwxrwx 1 bla bla 4096 Feb 01 20:10 foo1
-rwxrwxrwx 1 bla bla 4096 Feb 01 20:12 foo2
.
.
.
-rwxrwxrwx 1 bla bla 4096 Mar 05 13:25 foo1000
Run Code Online (Sandbox Code Playgroud)

为了只获得列表的最后一行,我应该在管道链中的 ls -ltr 后面添加什么?我知道有sed和awk,但我不知道如何使用它们,我只知道它们能做什么。

command-line ls sed awk

13
推荐指数
3
解决办法
5万
查看次数

通俗地说,套接字的目的是什么?

我多次遇到“socket”这个词,所以我在不同的网站上查了一下,但每个网站都需要太多的知识才能理解解释。

我读到的是这样的:

  • 套接字与管道和名称管道属于同一类别
  • 套接字提供某种双向通信
  • 套接字用于进程间通信
  • 有时会在网络方面提到套接字

我并没有真正了解大局,套接字的真正目的是什么。您能否用不需要太多技术知识的术语(如 C 语言)来解释它?

socket

12
推荐指数
0
解决办法
838
查看次数

如何从历史记录中的最后一个命令访问第二个参数?

我开始学习一些正则表达式,因此我反复使用这个命令:

grep pattern /usr/share/dict/american-english 
Run Code Online (Sandbox Code Playgroud)

只有模式变化的部分,所以我不得不一遍又一遍地写长表达“ /usr/share/dict/american-english ”。

有人评论说,可以通过键入神秘的字符组合而不是完整的表达式来从命令历史记录中扩展命令的参数。你能告诉我那些神秘的字符组合吗?

command-line bash command-history history-expansion

11
推荐指数
1
解决办法
2853
查看次数

如何使用管道在表达式上执行 watch 命令?

我今天学到了很棒的 shuf 命令:

ls | shuf  
Run Code Online (Sandbox Code Playgroud)

向我展示了工作目录的列表,但感谢 shuf 每次我用另一个命令执行这个管道命令表达式时。

所以我想,为什么不每一秒都重复这个表达,所以我尝试

watch -n1 ls | shuf          (and got no output)
watch -n1 (ls | shuf)        (and got an error)
watch -n1 {ls | shuf}        (and got an error)
Run Code Online (Sandbox Code Playgroud)

然后我把 ls | shuf 到它自己的文件中,并从中制作了一个脚本 foo 。

watch -n1 ./foo               (this times it worked)
Run Code Online (Sandbox Code Playgroud)

是否可以将 watch 命令应用于管道命令表达式,而无需将表达式制作成脚本文件?

command-line pipe shell-script watch

10
推荐指数
1
解决办法
4125
查看次数

当 .jpg 扩展名不是必需的时,如何在文件系统上查找所有 JPG 文件?

从 Windows 切换到 Linux 时,我注意到的第一件事是,Linux 没有严格的命名约定,也没有强制性的文件扩展名,例如 .bmp、.jpg、.exe 等。因此,我无法通过文件名本身来判断其文件格式。

如果我的文件系统上的所有 JPEG 文件都有 .jpg 扩展名,我可以通过以下方式简单地找到所有 JPEG 文件:

find / -type f -name "*.jpg"
Run Code Online (Sandbox Code Playgroud)

但如果不是这种情况,我不知道如何找到所有 JPEG 文件。

command-line find jpeg

9
推荐指数
1
解决办法
6万
查看次数

无法使用非整数时间选项调用 watch 命令

我想w周期性地启动命令,根据man watch最小可能的时间间隔是0.1。

我试过:

watch -n1 w        (works)
watch -n1.5 w      (does not work)
watch -n0.1 w      (does not work)
Run Code Online (Sandbox Code Playgroud)

当我尝试watch使用 n 选项作为非整数启动命令时,我收到错误消息:

watch: failed to parse argument: '0.1'
Run Code Online (Sandbox Code Playgroud)

command-line watch w

8
推荐指数
1
解决办法
2226
查看次数

标签 统计

command-line ×8

find ×2

pipe ×2

watch ×2

at ×1

awk ×1

bash ×1

command-history ×1

drivers ×1

history-expansion ×1

jpeg ×1

ls ×1

sed ×1

shell-script ×1

socket ×1

w ×1

xargs ×1