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
    • 最新
    • 标签
主页 / user-119603

bob dylan's questions

Martin Hope
bob dylan
Asked: 2022-09-21 19:13:27 +0800 CST

为什么 -e 选项不在 bash 命令手册中?

  • 13

我对 bash 手册中缺少的 -e 选项有点困惑。man bash

但它正在使用类似 : 的脚本 shebang #!/bin/bash -e,当然它是在help set.

为什么它没有列在 bash 手册的选项中?

bash man
  • 2 个回答
  • 2477 Views
Martin Hope
bob dylan
Asked: 2022-09-18 07:25:50 +0800 CST

PS1真的是环境变量吗?

  • 9

我一直认为这PS1是一个环境变量。但是当我检查 Ubuntu 的默认值并.bashrc检查PS1

grep PS1 /etc/skel/.bashrc

没有export PS1。

如果没有导出,是否意味着它不是环境变量?

environment-variables bash
  • 1 个回答
  • 874 Views
Martin Hope
bob dylan
Asked: 2019-01-14 15:57:53 +0800 CST

Ext4 错误和磁盘重新安装为只读

  • 2

有时我有一个错误 ext4,我的磁盘变成只读的。

我可以通过重新启动来修复它,fcsk /dev/sda2但它总是会回来......

这里有一些dmesg:

[ 3160.692730] perf: interrupt took too long (2509 > 2500), lowering kernel.perf_event_max_sample_rate to 79500                                                                                                                               
[ 3631.408303] perf: interrupt took too long (3144 > 3136), lowering kernel.perf_event_max_sample_rate to 63500                                                                                                                               
[ 4143.729000] perf: interrupt took too long (3992 > 3930), lowering kernel.perf_event_max_sample_rate to 50000                                                                                                                               
[ 4770.574303] perf: interrupt took too long (5018 > 4990), lowering kernel.perf_event_max_sample_rate to 39750                                                                                                                               
[ 5334.077445] perf: interrupt took too long (6289 > 6272), lowering kernel.perf_event_max_sample_rate to 31750                                                                                                                               
[ 8241.921553] acer_wmi: Unknown function number - 8 - 1                                                                                                                                                                                      
[11370.110956] perf: interrupt took too long (7918 > 7861), lowering kernel.perf_event_max_sample_rate to 25250                                                                                                                               
[11484.098212] acer_wmi: Unknown function number - 8 - 0                                                                                                                                                                                      
[11875.568601] EXT4-fs error (device sda2): ext4_iget:4862: inode #92441: comm TaskSchedulerFo: bad extra_isize 9489 (inode size 256)
[11875.575273] Aborting journal on device sda2-8.                                                                 
[11875.575537] EXT4-fs error (device sda2) in ext4_da_write_end:3209: IO failure                                  
[11875.575976] EXT4-fs (sda2): Remounting filesystem read-only                                                                       
[11875.576792] EXT4-fs error (device sda2): ext4_journal_check_start:61: Detected aborted journal                 
[11875.577612] EXT4-fs error (device sda2): ext4_iget:4862: inode #92441: comm TaskSchedulerFo: bad extra_isize 9489 (inode size 256)
[11875.583499] EXT4-fs error (device sda2): ext4_iget:4862: inode #92441: comm TaskSchedulerFo: bad extra_isize 9489 (inode size 256)
[11875.832886] EXT4-fs error (device sda2): ext4_iget:4862: inode #92441: comm TaskSchedulerFo: bad extra_isize 9489 (inode size 256)
[11899.686408] systemd-journald[395]: Failed to write entry (21 items, 614 bytes), ignoring: Read-only file system
[11899.686483] systemd-journald[395]: Failed to write entry (21 items, 705 bytes), ignoring: Read-only file system
[11899.686587] systemd-journald[395]: Failed to write entry (21 items, 614 bytes), ignoring: Read-only file system
[11899.686656] systemd-journald[395]: Failed to write entry (21 items, 705 bytes), ignoring: Read-only file system
[11899.686719] systemd-journald[395]: Failed to write entry (21 items, 614 bytes), ignoring: Read-only file system
[11899.686781] systemd-journald[395]: Failed to write entry (21 items, 705 bytes), ignoring: Read-only file system
[11899.686844] systemd-journald[395]: Failed to write entry (21 items, 614 bytes), ignoring: Read-only file system                   
[11899.686938] systemd-journald[395]: Failed to write entry (21 items, 705 bytes), ignoring: Read-only file system
[11899.686999] systemd-journald[395]: Failed to write entry (21 items, 614 bytes), ignoring: Read-only file system
[11899.687084] systemd-journald[395]: Failed to write entry (21 items, 705 bytes), ignoring: Read-only file system

我的/etc/fstab:

UUID=9c882ba5-b980-4f7d-dd02-cd0a1831ab1a /               ext4    errors=remount-ro 0       1
UUID=0E37-D0A2  /boot/efi       vfat    umask=0077      0       1
/swapfile                                 none            swap    sw              0       0

我应该删除或更改remount-ro并fstab忽略此错误吗?如何修复/避免此错误?

linux filesystems
  • 1 个回答
  • 11464 Views
Martin Hope
bob dylan
Asked: 2018-12-06 03:38:46 +0800 CST

要求 sed 忽略所有特殊字符 [重复]

  • 4
这个问题在这里已经有了答案:
在 sh 脚本中使用 sed 时需要转义哪些字符? (4 个回答)
3年前关闭。

我使用以下代码删除一行:

sed -i "0,/$DELETE_THIS/{/$DELETE_THIS/d;}" file.txt

但是,如果变量DELETE_THIS包含特殊字符(如.、等) /,此代码将失败*...

有没有办法告诉sed忽略所有特殊字符并将它们用作基本文本?

regular-expression sed
  • 1 个回答
  • 6263 Views
Martin Hope
bob dylan
Asked: 2018-12-05 07:15:30 +0800 CST

将值发送到脚本中的“读取”

  • 0

是否可以在 shell 脚本中发送对“交互式菜单”的响应,但在调用它时直接发送?

例如,脚本test.sh:

#!/bin/bash
sleep 2 #Or something else
echo "menu, select 1 for...."
read choice
if [ $choice -eq 1 ]; then
  echo AMAZING
fi

在不更改脚本代码的情况下,我如何调用脚本test.sh并自动将他1作为我的下一个选择发送给他。read

bash shell-script
  • 1 个回答
  • 328 Views
Martin Hope
bob dylan
Asked: 2018-11-28 02:34:03 +0800 CST

我们应该在 bash/shell 脚本中使用像 ⏰ 这样的 UTF-8 字符吗?

  • 36

如果使用以下命令启动,此处的简单代码将在我的机器上按预期工作bash:

function ⏰(){
 date
}
⏰

其他人使用它会不会有问题,还是通用的?

我想知道,因为我现在从未在其他源代码中看到过这样的东西。

编辑:有无限的可能性,它可以用来快速区分功能角色,例如使用表情符号。

? 表示可以修改或删除文件的功能,? 表示正在进行的工作,? 表示交互式菜单...

我想我们应该为所有这些创建一个标准,但这似乎是一个有趣的想法。
也许约 5 个字符的随机行可以帮助我们更好地理解代码在做什么。(当然,我们需要学习如何阅读它们。)

更多编辑:我试一试。现在,如果我在编辑器(或cat myscript.sh|grep function)中折叠所有功能,它们看起来像这样。geany(与这里相比,我的 unicode 在或我的终端中看起来好多了。)

function ⬚_1(){
function ⬚⬚_2(){
function ⬚⬚⬚_?_D(){
function ⬚⬚⬚⬚_?_X(){
function ⬚⬚⬚⬚⬚_?_Y(){
function ⬚⬚⬚⬚⬚⬚_❓_P(){
function ⬚⬚⬚⬚_?_Z(){
function ⬚⬚⬚⬚⬚_❓_U(){
function ⬚⬚⬚⬚⬚_❓_O(){

我使用了一个奇怪的缩进 ⬚ 来显示函数之间的关系,并使用符号 ?/❓ 来清楚地区分它们的作用。(当然这些不是我真正的函数名,我只是在末尾放了一个随机的字母,但即使没有它们我们也可以清楚地看到它们之间的关系。)

bash shell
  • 1 个回答
  • 5861 Views
Martin Hope
bob dylan
Asked: 2018-10-18 20:27:43 +0800 CST

关闭父 shell 后进程 PPID 更改为 1

  • 3

firefox&打开一个新终端并在里面输入命令,ps -l给出:

4 R  1000 23132 23104 99  80   0 - 2177945 -    pts/27   00:00:07 firefox

如果使用该命令关闭 shell exit,则 firefox 子进程保持打开状态!

总是这样吗?Firefox 不应该也关闭吗?最近的内核中是否有新的东西或我缺少的东西?

结果ps -el|grep firefox是:

4 S  1000 23132     1 14  80   0 - 2233312 poll_s ?      00:00:21 firefox

PPID 已更改为 1。

是什么导致此 PPID 更改为 1 ?

编辑:哦,我刚刚意识到关闭终端和关闭 shell 有非常不同的结果:关闭终端确实关闭了所有子进程,但不是当 shell 用 exit 命令关闭时......不知道为什么。(关闭终端正在向所有子进程发送 SIGTERM ?但关闭 shell 会留下孤儿?)

linux bash
  • 1 个回答
  • 2675 Views
Martin Hope
bob dylan
Asked: 2018-09-30 05:01:57 +0800 CST

检查变量是否是小于给定数字或等于文本“QUIT”的数字

  • 2

只要 $CHOICE 不是“QUIT”或小于给定整数(变量)的数字,我就会留在这个循环中。

我正在使用这个:(以 22 为例)

NUMBER=22
CHOICE=99
while [ "$CHOICE" -gt "$NUMBER" ] && [ "$CHOICE" != "QUIT" ]; do
  read CHOICE < /dev/tty
done

但是如果我说“测试”,脚本就会崩溃,因为它在第一个测试中需要一个整数。

我能做些什么来避免这种崩溃?

bash
  • 3 个回答
  • 1209 Views
Martin Hope
bob dylan
Asked: 2018-09-11 03:48:13 +0800 CST

Trap 'Ctrl + c' 用于 bash 脚本,但不用于在此脚本中打开的进程

  • 11

我试图在 bash 脚本中有一个交互式程序:

my_program

我希望能够用'Ctrl + c'关闭它。但是当我这样做时,我的脚本也会关闭。

我知道。

trap '' 2
my_program
trap 2

但在这种情况下,我无法my_program使用 Ctrl + c 关闭。

您知道如何在程序上允许 Ctrl + c,但不关闭运行它的脚本吗?

编辑:添加示例

#!/bin/bash
my_program
my_program2

如果我使用 Ctrl + c 关闭my_program,my_program2则永远不会执行,因为整个脚本都已退出。

bash trap
  • 3 个回答
  • 2986 Views
Martin Hope
bob dylan
Asked: 2018-08-30 01:00:24 +0800 CST

切换到其他输入法

  • 0

我找不到任何关于 linux 如何处理键盘的信息。(基于系统的配置不​​是 gui)

我的问题是:我安装ibus了linux mint多种语言,但它只是不起作用,尽管ibus-setup...ibus-daemon -rx

也许我的系统使用的是另一种输入法而不是ibus?是否有命令可以知道我的计算机实际使用的是哪种输入法?

linux-mint keyboard
  • 1 个回答
  • 1898 Views

Sidebar

Stats

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

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

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

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve