小编sol*_*ish的帖子

$# 在 bash 中是什么意思?

我在名为 instance 的文件中有一个脚本:

echo "hello world"
echo ${1}
Run Code Online (Sandbox Code Playgroud)

当我使用以下命令运行此脚本时:

./instance solfish
Run Code Online (Sandbox Code Playgroud)

我得到这个输出:

hello world
solfish
Run Code Online (Sandbox Code Playgroud)

但是当我运行时:

echo $# 
Run Code Online (Sandbox Code Playgroud)

它说“0”。为什么?我不明白什么$#意思。

请解释一下。

bash

45
推荐指数
4
解决办法
7万
查看次数

如何在grep中包含空格字符?

我有一个名为 example 的文件

$ cat example

kali.pdf
linux.pdf
ubuntu.pdf
example.pdf.
this.pdf
grep .pdf
Run Code Online (Sandbox Code Playgroud)

当我grep用来获取之前有空格的行时.pdf,我似乎无法获取它。

grep *.pdf example
Run Code Online (Sandbox Code Playgroud)

什么都不返回,(我想说,“grep,在之前匹配零个或多个空格.pdf”,但没有结果)

如果我使用:

grep i*.pdf example

kali.pdf
linux.pdf
ubuntu.pdf
example.pdf.
this.pdf
grep .pdf
Run Code Online (Sandbox Code Playgroud)

所有行都返回,因为我在说“grep,匹配我i一次或零次,好的。”

最后:

grep " *.pdf" example
Run Code Online (Sandbox Code Playgroud)

没有结果返回

对于这个样本,我想看看

grep .pdf 
Run Code Online (Sandbox Code Playgroud)

作为输出

我的想法有什么问题?

command-line regex grep

24
推荐指数
1
解决办法
12万
查看次数

取出“拒绝访问”行

当我find用来查看目录中的所有 pdf 文件时/home,我看到的是access denied. 为了消除它们,我尝试过:

find /home -iname "*.pdf" | grep -v "access denied"
Run Code Online (Sandbox Code Playgroud)

然而,结果是一样的。我怎样才能摆脱这些线?

command-line bash find

9
推荐指数
2
解决办法
2554
查看次数

IO Block的含义是什么以及如何计算?

我想知道“IO Block”在输出中的含义stat以及该数字是如何计算的。

我知道文件夹/文件的物理大小以 4096 字节块来衡量。

然而,在下面的示例中,文件的大小超过 4096 字节,并且“IO Block”的值没有改变。

IO块的含义是什么以及如何更改?

stat yeni
  File: 'yeni'
  Size: 12890           Blocks: 32          IO Block: 4096   normal dosya
Device: 805h/2053d  Inode: 2255976     Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1000/   ihsan)   Gid: ( 1000/   ihsan)
Access: 2017-08-15 20:07:26.324017949 +0300
Modify: 2017-08-15 20:06:30.703053636 +0300
Change: 2017-08-15 20:07:26.324017949 +0300
 Birth: -
Run Code Online (Sandbox Code Playgroud)

command-line disk-usage

5
推荐指数
2
解决办法
6122
查看次数

如何从我的系统中删除 conky?

我最近安装了“conky”,但我想现在卸载它。
我试过:

sudo apt-get remove conky
sudo apt-get purge conky
Run Code Online (Sandbox Code Playgroud)

运行这些命令后,我仍然可以从终端运行 conky。

我怎样才能真正删除它?

software-uninstall

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

egrep 命令用于查找以一个字符开头且还包含一些字符串的行

假设我有一个有一些ls -l输出的文件:

waaa- foo.pdf
-bbb- foobar.pdf
-ccc- foobar
waaa- foobar
Run Code Online (Sandbox Code Playgroud)

我只想得到第一行

waaa -foo.pdf
Run Code Online (Sandbox Code Playgroud)

作为最终结果,我正在尝试:

egrep -E "^w" .file | egrep -E "*.pdf"
Run Code Online (Sandbox Code Playgroud)

有没有办法将这两个搜索结合起来?

command-line grep

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

标签 统计

command-line ×4

bash ×2

grep ×2

disk-usage ×1

find ×1

regex ×1

software-uninstall ×1