AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题

问题[dash-shell](ubuntu)

Martin Hope
AndreaNobili
Asked: 2019-11-24 03:19:29 +0800 CST

为什么我的 shell 不能自动完成工作?

  • 9

我不太喜欢 Linux,我有以下疑问:一个客户端为我提供了一个 Ubuntu 18.04.3 LTS 虚拟机,我通过 SSH 访问它。(我使用 MobaxTerm 作为 SSH 客户端,但这应该不是问题。)使用的 shell 是sh.

问题是在 shell 中,自动完成功能没有像我预期的那样使用Tab密钥。

它只是简单地放置了经典的制表符空白。

为什么?如何更改此配置?

command-line auto-completion sh dash-shell
  • 1 个回答
  • 11133 Views
Martin Hope
BlueSkies
Asked: 2019-11-06 12:10:19 +0800 CST

如何在 grep 匹配后列出两行?

  • 2
grep 'STRING' filename

在文件中搜索 STRING 并列出包含匹配项的行。我怎样才能列出匹配后的两行?

scripts command-line grep dash-shell
  • 1 个回答
  • 128 Views
Martin Hope
Mazhar MIK
Asked: 2019-08-08 01:17:06 +0800 CST

解压缩具有有限层次结构的文件

  • 1

我在终端中创建了一个 tar 文件。假设我目前在目录 test7 中。我正在另一个目录(test8)内的文件的当前目录中创建一个 tar。

tar -czvf example.tgz ../test8/a/b

输出:

example.tgz

现在,我使用以下命令解压此文件:

tar -xzvf example.tgz

我得到了结果,并生成了一个名为test8的目录。

$) cd test8

$) ls
-> a

$) cd a

$) ls
-> b

现在我可以进入目录b并查看我的文件。

我希望输出只是目录a,其中b将出现在其中,即解压后的输出,我想要的应该是这个层次结构: a/b 但不是:test8/a/b

谁能帮我解决这个问题?我已经浏览了 tar 的手册页,但无法从中获得太多帮助。

tar dash-shell
  • 1 个回答
  • 63 Views
Martin Hope
Jackie Nelson
Asked: 2019-03-08 01:33:56 +0800 CST

如何在shell中连接两个命令

  • 7

我曾经有这个命令来计算我用鼠标点击了多少次,命令是xev | grep "ButtonPress"。

我的同事修改命令使其返回:

ButtonPress 0
ButtonPress 1
ButtonPress 2
ButtonPress 3

等等……不幸的是,他不再联系上了,所以我再也联系不到他了。

我记得参与i++和类似的事情,如何重现命令?

scripts command-line bash dash-shell
  • 1 个回答
  • 802 Views
Martin Hope
Stephen Ostermiller
Asked: 2018-11-08 12:46:52 +0800 CST

update-alternatives for sh 报告 bash 被使用,但我仍然得到破折号

  • 4

我刚刚从 Ubuntu 17.10 升级到 Ubuntu 18.10。

我将我的盒子配置为bash用作默认 shell 而不是默认的dash. 我已经通过以下sudo update-alternatives --config sh报告进行了此更改:

  Selection    Path            Priority   Status
------------------------------------------------------------
  0            /bin/dash        200       auto mode
* 1            /bin/bash        100       manual mode
  2            /bin/dash        200       manual mode

但是,/bin/sh仍然指向dash而不是指向bash。

实际上,在以前版本的 Ubuntu 上,我相信曾经指向/bin/sh -> /etc/alternatives/sh.

看起来最新的 Ubuntu 在升级过程中不再允许alternatives或sh至少破坏了替代方案。我从How Can I Make /bin/sh point to /bin/bash? 现在建议重新配置破折号。

为什么不再alternatives工作了?此更改记录在哪里?我在 Ubuntu 中使用 sh 的替代品至少三年了,而且在升级之前我从来没有遇到过它的问题。有许多指南建议,例如:https ://jwaghetti.blogspot.com/2015/09/sharing-dash-to-bash.html

bash sh dash-shell update-alternatives
  • 1 个回答
  • 3066 Views
Martin Hope
Srik_Aanth
Asked: 2018-09-19 23:53:33 +0800 CST

我需要使用 shell 脚本在两个模式之间插入一个大字符串

  • 1

我有一个 HTML 文件,其中有一个注释行:

<!-- tag1 --><!-- tag11 --> 

我需要JQ在它们之间插入一个文件元素。

我已经尝试过,我能够插入一个小字符串,但我的字符串很大。谁能给我一个想法?

i=0
code="(jq -r '.["$i"].code' file.json)"; 
eval v=\$$code; 
sed -i 's/(<!-- tag1 -->)\(<!-- tag11 -->)/\1'$v'\2/' index.html;

它给我一个错误:

sed: -e expression #1, char 47: unterminated `s' command

然而:

v="xxxxxxx" 
sed -i 's/(<!-- tag1 -->)\(<!-- tag11 -->)/\1'$v'\2/' index.html;

字符串插入完美有人可以帮忙吗?

scripts command-line bash sed dash-shell
  • 1 个回答
  • 309 Views
Martin Hope
mkasberg
Asked: 2018-08-13 13:36:23 +0800 CST

如何使 /bin/sh 指向 /bin/bash?

  • 6

在 Ubuntu 中,默认/bin/sh指向./bin/dash

我想/bin/bash用作我的系统范围的外壳程序/bin/sh。做这个的最好方式是什么?

bash dash-shell
  • 1 个回答
  • 18507 Views
Martin Hope
guettli
Asked: 2018-07-26 11:53:53 +0800 CST

关于 bash 与 dash 的速度是否有具体数字?

  • 7

根据这篇文章,dash被选为/bin/sh因为bash速度较慢:Dash as /bin/sh

是否有具体数字说明速度快多少dash?

bash如果您使用而不是dash启动 Ubuntu ,需要多长时间?

上述链接的论点今天仍然有效吗?对于背景:system-v init 使用了很多 shell 脚本,但 systemd 没有。

这个问题与综合基准测试中的速度无关。这关乎最终用户的整体显着利益。关于 dash 与 bash 速度的综合基准无法回答这个问题。

bash benchmarks dash-shell
  • 1 个回答
  • 2236 Views
Martin Hope
Sergiy Kolodyazhnyy
Asked: 2018-06-05 15:27:17 +0800 CST

破折号,命令替换不插入换行符?

  • 1

基本上,这是一个问题:

$ echo Hello"$(printf '\n')"World
HelloWorld

我忽略了什么?

command-line dash-shell
  • 1 个回答
  • 285 Views
Martin Hope
NerdOfLinux
Asked: 2018-04-25 06:07:04 +0800 CST

〜/如何工作?[复制]

  • 10
这个问题在这里已经有了答案:
如何使用波浪号作为我的主目录的快捷方式? (4 个回答)
4年前关闭。

在终端中,引用 home 的一种方法是使用~/. 我不明白这是如何工作的,因为输出file ~/是:

/home/admin/: directory

并且只是运行~/结果:

-bash: /home/admin/: Is a directory

那么转换~/成/home/admin什么?

~/似乎也适用于/bin/dash,所以我也知道它不是特定于 bash 的。

home-directory command-line bash sh dash-shell
  • 2 个回答
  • 1156 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve