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
    • 最新
    • 标签
主页 / unix / 问题

问题[busybox](unix)

Martin Hope
anthumchris
Asked: 2024-12-07 23:35:56 +0800 CST

如何在 Alpine Linux(busybox、ash)中按编号执行历史命令?

  • 5

是否可以!###像 bash/zsh 一样通过数字执行历史命令?Alpine 的 ash shell 无法解释这一点:

$ history
1441 date
1442 history

$ !1141
-sh: !1141: not found
busybox
  • 1 个回答
  • 31 Views
Martin Hope
tgs
Asked: 2023-10-29 18:25:56 +0800 CST

重启后加载 /opt/etc/profile 文件的内容

  • 5

我有一个 ZyXEL NAS326 网络驱动器,它运行 BusyBox v1.19.4 以及一个附加的 OpenWrt 存储库。每次重新启动后,系统看不到 OpenWrt 二进制文件的路径,也不会记住命令历史记录。即使我运行命令. /opt/etc/profile,然后重新启动后也没有命令历史记录,也没有 OpenWrt 二进制文件的路径。此 NAS 上的默认控制台是 ash。如何配置系统,使系统始终在控制台中有活动的命令历史记录,并可以访问路径中的 OpenWrt bianrium?

busybox
  • 1 个回答
  • 15 Views
Martin Hope
jokoyoporo
Asked: 2022-10-05 05:31:04 +0800 CST

为什么在busybox sh中运行异步作业需要/dev/null?

  • 0

我很好奇为什么需要这个特殊的设备来分叉命令并在最小的 Busybox shell 中异步运行它。

BusyBox v1.30.1 (Debian 1:1.30.1-4) built-in shell (ash)
Enter 'help' for a list of built-in commands.

/bin/sh: can't access tty; job control turned off
/ #
/ # echo Hello && sleep 2s && echo World &
/bin/sh: / # can't open '/dev/null': No such file or directory

/ #
/ # mknod /dev/null c 1 3 && chmod 666 /dev/null
/ # echo Hello && sleep 2s && echo World &
/ # Hello
World

/ #
busybox subshell
  • 1 个回答
  • 38 Views
Martin Hope
abacox
Asked: 2022-01-19 19:23:14 +0800 CST

为什么我不能修剪这个目录?

  • 0

busybox version 1.33.0

我正在尝试复制整个home文件夹。

在home,内部/dev/sda2/安装,如下所示:

/home/user/sda2
/home/user/sda2/root
/home/user/sda2/home_backup

您可以在上面看到root/目录sda2/,由实际拥有root。此外,还有home_backup/哪些将存储来自/home.

我的问题是:

执行以下行后,我得到了一个很好的文件列表,/home/user/sda2并且它的内容无处可寻,这正是我想要的:

LC_ALL=C find /home -path /home/user/sda2 -prune -o -iname '*' -print \;

但是对于以下内容,我总是收到operation not permitted目录错误root/(准确,我不是所有者,普通用户),这意味着它不会sda2像我预期的那样修剪:

LC_ALL=C find /home -path /home/user/sda2 -prune -o -iname '*' -exec cp -r '{}' /home/user/sda2/home_backup/ ;/

由于显而易见的原因/home/user/sda2,必须排除,不要一遍又一遍地复制相同的数据。

检查这个并不能真正回答我的问题,但它让我对如何prune工作有了一个概念。

https://stackoverflow.com/questions/1489277/how-to-use-prune-option-of-find-in-sh/1489405#1489405

编辑

我刚刚意识到,在上一行中,所有文件都将混合在一起,home_backup但这不是问题,我仍然想知道为什么我不能正确“修剪”。

find busybox
  • 1 个回答
  • 37 Views
Martin Hope
Huzi
Asked: 2021-11-30 20:01:11 +0800 CST

busybox --install [-s] [DIR] 中的 -s 选项代表什么?

  • 0

键入时busybox --help,其中一种用法是:busybox --install [-s] [DIR]. -s选项代表什么?

busybox
  • 1 个回答
  • 472 Views
Martin Hope
abacox
Asked: 2021-10-25 22:24:23 +0800 CST

如何替换/删除新行(\n)?

  • -1

我busybox 1.27.2只能访问。

我目前正在处理一本包含超过 50 万字和 6,000 多页的字典(从带有 ghostscript 的 PDF 中提取并转换为纯文本)。在一个20MB .txt文件中。最初,这本词典中的每个单词都有一个前导->,以便于搜索单词。

我想要实现的是让它变得*nix友好。这意味着如果我这样做: grep -e '->myfancyword' ./dictionary.txt.

结果我应该得到:

->fancyword: This is a very fancy word. *Definition going on for more than 6 lines*

这很容易通过去除所有换行符来完成,\n因此每个单词都将在很长的一行中包含其所有定义,这没关系。我可以用所有替换\n,tr -d '\n'然后通过它的输出,sed 's/->/\n->/g'所以我将在一行中得到所有单词的定义。即使在这个巨大的文档上,它也可以在不到 5 秒的时间内完成。

我几乎得到了我想要的结果,但并不完美。我可以做到这一点grep -e '->word' ./dictionary.txt并得到这个词的完整定义。但它在外观上并不完美。

我对输出不满意的原因是因为原始 pdf 被格式化为打印在A4页面上,这意味着当有一个长单词时,它被切掉了。像这样:

例如

->word: This is a defini-
tion.

如果我使用以前的工作流程处理文件,我得到:->word: This is a defini- tion.当 grepping 所需的单词时。

到目前为止,我设法完成的是:

  1. 输入
->firstword: This is a defini-
tion.
->secondword: This is a second defini-
tion.
  1. 应用 tr -d '\n' < ./dictionary.txt > ./dictionary2.txt

  2. 输出是:

->firstword: This is a defini- tion. ->secondword: This is a second defini- tion.
  1. 跑了:sed -e 's/->/\n->/g' ./dictionary2.txt

  2. 结束于:

输出

->firstword: This is a defini- tion.
->secondword: This is a second defini- tion.

在进行第二步之前,我想删除破折号和换行符 ( -\n) 以将所有切碎的线“连接”在一起。

所以,我的问题是:如何替换/删除行尾包含破折号-和换行符\n( -\n) 的特定字符串?

我喜欢得到的是:

输出(请检查破折号和空格(- )不再存在)

->firstword: This is a definition.
->secondword: This is a second definition.

谢谢你。

编辑:

这是PDF文件的页面:


     ->abigeato. (Del lat. abigeatus). 1. m. Am. Hurto de ganado.
     ->abigeo. (Del lat. abigeus). 1. m. Am. Ladrón de ganado.
     ->abigotado, da. 1. adj. bigotudo.
     ->abinar. 1. tr. rur. y vulg. Binar la tierra.
     ->abintestato. (De ab intestato). 1. m. Der. Procedimiento judicial sobre herencia y
   adjudicación de bienes de quien muere sin testar.
     ->abiogénesis. (De a-2, bio- y -génesis). 1. f. Producción hipotética de seres vivos par-
   tiendo de materia inerte. 2. f. Bioquím. síntesis abiótica.
     ->abiótico, ca. 1. adj. Biol. Se dice del medio en que no es posible la vida.  V. síntesis
   abiótica
     ->abipón, na. 1. adj. Se dice del individuo de un pueblo amerindio que habitaba cerca del
   Paraná. U. t. c. s. 2. adj. Perteneciente o relativo a los abipones. 3. m. Lengua de la familia
   guaicurú hablada por los abipones.
     ->abisagrar. 1. tr. Clavar o fijar bisagras en las puertas y sus marcos, o en otros objetos.
     ->abisal. (Del lat. abyssus). 1. adj. abismal (|| perteneciente al abismo). 2. adj. Se dice de
   las zonas del mar profundo que se extienden más allá del talud continental, y corresponden a
   profundidades mayores de 2000 m. 3. adj. Perteneciente o relativo a tales zonas.
     ->abiselar. 1. tr. biselar.
     ->abisinio, nia. 1. adj. Natural de Abisinia, hoy Etiopía. U. t. c. s. 2. adj. Perteneciente o re-
   lativo a este país de África. 3. m. Lengua abisinia.  V. rito abisinio
     ->abismado, da. (Del part. de abismar). 1. adj. Dicho de una persona, de su expresión, de
   su gesto, etc.: Ensimismados, reconcentrados. 2. adj. Heráld. Dicho de una pieza del escudo:
   Puesta en el abismo.
     ->abismal (1).  (Del ár. hisp. almismár, y este del ár. clás. mismar). 1. m. Cada uno de los
   clavos con que se fijaba en el asta el hierro de la lanza.abismal2. 1. adj. Perteneciente o re-
   lativo al abismo. 2. adj. Muy profundo, insondable, incomprensible.
     ->abismar. 1. tr. Hundir en un abismo. U. t. c. prnl. 2. tr. Confundir, abatir. U. t. c. prnl. 3.
   prnl. Entregarse del todo a la contemplación, al dolor, etc. 4. prnl. Am. sorprenderse (|| con-
   moverse con algo imprevisto o raro).
     ->abismático, ca. 1. adj. abismal2.
     ->abismo. (Quizá del lat. vulg. *abyssimus, der. de abyssus, y este del gr. , sin fondo). 1.
   m. Profundidad grande, imponente y peligrosa, como la de los mares, la de un tajo, la de una
   sima, etc. U. t. en sent. fig. Se sumió en el abismo de la desesperación. 2. m. infierno (|| lugar
   de castigo eterno). 3. m. Cosa inmensa, insondable o incomprensible. 4. m. Diferencia
   grande entre cosas, personas, ideas, sentimientos, etc. 5. m. Heráld. Punto o parte central
   del escudo. 6. m. Nic. Maldad, perdición, ruina moral.

这是在使用 ghostscript 完成提取后对常规文本进行 grepping 时得到的结果(仅使用 dos2unix 处理):


grep -e '->abiog' ./rae-dos2unix.txt
     ->abiogénesis. (De a-2, bio- y -génesis). 1. f. Producción hipotética de seres vivos par-

这是在文本上完成前面的步骤(1-4)时,当我得到:


grep -e '->abiog' ./rae-una-linea.txt
->abiogénesis. (De a-2, bio- y -génesis). 1. f. Producción hipotética de seres vivos par-   tiendo de materia inerte. 2. f. Bioquím. síntesis abiótica.     

text-processing busybox
  • 2 个回答
  • 397 Views
Martin Hope
user3142695
Asked: 2021-10-04 11:46:59 +0800 CST

如何在脚本中生成一串串联的键/值对?

  • 0

--build-arg我需要在busybox shell 中使用一些键/值对(build.args 文件)来构建参数字符串:

脚本.sh

#!/bin/sh
one=$1
two=$2
shift

while IFS= read -r line; do
    set "$@" --build-arg "$line"
done < "build.args"

echo "$@"

构建.args

ONE=first
TWO=second

运行sh script.sh foo bar(是的,脚本需要两个参数)应该读取 build.args 的内容并添加键/值对作为--build-arg参数并输出这个生成的字符串。这是我所期待的:

--build-arg ONE=first --build-arg TWO=second

但是用我的脚本我确实得到了

bar --build-arg ONE=first --build-arg TWO=second

asbar在脚本调用中作为第二个参数传递。

shell busybox
  • 1 个回答
  • 197 Views
Martin Hope
user395294
Asked: 2020-02-14 09:16:22 +0800 CST

Kindle e-ink 帮助 - 显示随机图像文件

  • 3

我对此完全是新手,但我正在尝试将其他人的代码改编为越狱的 Kindle 3(电子阅读器)。

我正在使用以下代码生成一个介于 0 到 X 之间的随机(ish)数字(其中 X 是我拥有的图像数量,目前为 33),这样我就可以每隔这么多小时(目前每 2 小时)显示一个随机图像)cron用于运行脚本。

#generate random number between my 33 images (compatible with busybox)
n=32
while [ $n -ge 32 ]; do
n=1$(</dev/urandom tr -dc 0-9 | dd bs=5 count=1 2>/dev/null)
n=$((n-100000))
done
ImageNumber=$n

#My images are numbered as follows - pic_0.png, pic_1.png, pic_3.png... etc
SelectedImage=$( find /mnt/us/timelit/images/pic_${ImageNumber}*.png)

# clear the screen
eips -c

# show that image
eips -g $SelectedImage

它正在工作,但是有几件事需要解决。

1)我认为脚本的随机数生成器部分存在问题,因为它在生成数字之前随时间变化(见下面的日志)

14:00:02: Script started
14:02:43: Random number is 2 
14:02:44: Image shown is pic_2.png 
15:00:02: Script started
15:00:19: Random number is 18 
15:00:20: Image shown is pic_18.png 
16:00:01: Script started
16:02:44: Random number is 10 
16:02:45: Image shown is pic_10.png  

2) Kindle 时不时地显示一个空白屏幕,而不是其中一个图像。我猜测生成的随机数存在问题,这意味着找不到具有匹配数字的 PNG,因此 Kindle 显示为空白。

任何帮助是极大的赞赏。

shell busybox
  • 2 个回答
  • 123 Views
Martin Hope
GENIVI-LEARNER
Asked: 2020-02-09 15:02:30 +0800 CST

为嵌入式 Linux 平台构建内核映像

  • -1

我有兴趣为基于 Ingenic SoC 的平台编译 linux 映像。供应商含糊地提供了有关如何为目标 SoC 编译 linux 内核的说明。因此,根据供应商说明和在线搜索,需要以下内容才能获得该平台的嵌入式 linux 映像。

  1. 编译工具链(mipsel for mips based architecture)
  2. 使用工具链使用给定的驱动程序/BSP 编译 linux 内核
  3. 编译根文件系统 - Busybox 建议(不知道为什么)
  4. 为目标 SoC 编译 uBoot
  5. 使用目标特定的分区表对 sd 等存储进行分区
  6. 将整个图像刷入sd

所以问题是,为什么根文件系统与内核映像是分开的?busybox 在生成文件系统中起什么作用?另外,如果 linux 映像是在没有根文件系统的情况下编译的,如何将两者合并以在根文件系统的 /sys 目录中拥有驱动程序?

linux-kernel busybox
  • 1 个回答
  • 553 Views
Martin Hope
DrP3pp3r
Asked: 2020-01-11 05:13:01 +0800 CST

udhcpc:如果 DHCP 服务器提供 IP 地址而不是主机名,则 DHCP 选项 66 变量 tftp 包含“错误”

  • 2

我正在开发一个嵌入式 Linux,它使用BusyBox和udhcpc(BusyBox的一部分)作为其 DHCP 客户端。

如果我将 DHCP 服务器配置为在 DHCP 选项 66 中提供 FTP 服务器,那么只要选项包含主机名(可能是有效的 DNS 名称?!),一切都很好(即其中的tftp变量包含配置的值)。/etc/udhcpc.script如果选项包含 IP 地址,则变量tftp包含值“bad”。

这种行为的原因和意义是什么?

我在udhcpc文档中找不到有关此行为的任何信息(https://udhcp.busybox.net/README.udhcpc、https://udhcp.busybox.net/ ) ,也没有在 Google 上获得任何有用的搜索结果。

RFC2132不包含在此选项中不允许 IP 地址的任何限制(据我了解)。

有什么方法可以从 udhcpc 中的选项 66 获取 IP 地址?

dhcp busybox
  • 1 个回答
  • 864 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