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-1269127

Saeed Neamati's questions

Martin Hope
Saeed Neamati
Asked: 2024-05-05 17:09:19 +0800 CST

在 Ubuntu 24.04 中,无法点击最大化应用程序的整个右上角

  • 6

我在一台 PC 上安装了全新的 Ubuntu 24.04。

现在的问题是,任何最大化应用程序的整个右上角都无法点击。

在此处输入图片描述

您知道可能出现什么问题以及如何解决它吗?

24.04
  • 1 个回答
  • 369 Views
Martin Hope
Saeed Neamati
Asked: 2023-09-13 15:45:44 +0800 CST

如何将“find”命令升级到最新版本?

  • 6

我得到了Is it possible to chain two Continuous find Commands?的答案 去年。

今天我想测试将两个find命令连接在一起的最新建议。

find ... -print0 | find -files0-from - ...

令我惊讶的是它不起作用,我收到了这个错误:

查找:未知谓词“-files0-from”

我检查了file使用的版本file --version,它是find (GNU findutils) 4.8.0

这让我很困惑,因为我使用Ubuntu 22.04.3 LTSapt update && apt upgrade并且每天都运行。

那么,如何将find命令更新到最新版本呢?

command-line
  • 1 个回答
  • 37 Views
Martin Hope
Saeed Neamati
Asked: 2023-08-15 15:52:34 +0800 CST

bash 中如何知道 JSON 数组是空数组?

  • 5

我使用此代码来使用 GitHub API 并自动执行一些任务:

curl --silent -H 'Authorization: token github_access_token' 'https://api.github.com/orgs/OrganizationName/repos?per_page=100'

有时我得到这样的回应:

[

]

我想知道响应是否是空数组。

我想过使用jqlikeecho $Response | jq -r ".[]"但我不知道如何从那里继续。

如何在 bash 中找出 JSON 字符串是否为空数组?

command-line
  • 2 个回答
  • 37 Views
Martin Hope
Saeed Neamati
Asked: 2023-08-08 13:30:51 +0800 CST

如何通过 shell 禁用动态工作区并切换到固定数量?

  • 7

我可以使用此命令通过 shell 设置工作区的数量:

gsettings set org.gnome.desktop.wm.preferences num-workspaces 9

但我找不到将其从“动态工作区”更改为“固定数量工作区”的关键。

我怎样才能在外壳中做到这一点?

command-line
  • 1 个回答
  • 27 Views
Martin Hope
Saeed Neamati
Asked: 2022-12-27 02:35:13 +0800 CST

如何使用 ImageMagick 调整图像大小

  • 5

从如何通过命令行轻松调整图像大小?我知道我可以使用此命令在 bash 中调整图像大小:

convert -resize 1024X768  source.png dest.jpg

但我坚持只提供宽度并保持纵横比。

man convert不为-resize标志提供任何帮助。

我想要类似的东西convert -resize 1024 -keep-ratio source.png dest.png

命令是什么?

command-line
  • 1 个回答
  • 44 Views
Martin Hope
Saeed Neamati
Asked: 2022-09-19 20:22:35 +0800 CST

坚持在heredoc中使用双引号

  • 0

我正在尝试运行此代码:

    while read Item; do
        export environmentVariables="$environmentVariables\n      - $Item"
    done <<< "$(
        cat /LocalSecrets/EnvironmentVariables.json |
        jq -r 'to_entries[] | "\(.key)=\(.value)"' |
    )"

我有一个简单的 JSON 文件,位于/LocalSecrets/EnvironmentVariables.json. 这是一个简单的键/值对 JSON 对象:

{
    "FirstKey": "FirstValue",
    "SecondKey": "SecondValue",
    "ThirdKey": "ThirdValue"
}

我想使用它来阅读它jq并将它们全部附加到一个shell变量中$environmentVariables,例如:

FirstKey=FirstValue
SecondKey=SecondValue
ThirdKey=ThirdValue

但是由于jq在它的命令中需要双引号,并且我需要使用heredoc来保存$environmentVariables循环中的当前shell,所以我被卡住了。该代码无法运行,并且存在语法错误。

我应该怎么办?我也对其他解决方案持开放态度。

bash
  • 1 个回答
  • 46 Views
Martin Hope
Saeed Neamati
Asked: 2022-05-17 21:00:09 +0800 CST

如何获得平均 ping 时间?

  • 1

ping 192.168.1.1这是我的命令的真实结果:

64 bytes from 192.168.1.1: icmp_seq=964 ttl=64 time=1018 ms
64 bytes from 192.168.1.1: icmp_seq=965 ttl=64 time=921 ms
64 bytes from 192.168.1.1: icmp_seq=966 ttl=64 time=847 ms
64 bytes from 192.168.1.1: icmp_seq=967 ttl=64 time=866 ms
64 bytes from 192.168.1.1: icmp_seq=968 ttl=64 time=895 ms
64 bytes from 192.168.1.1: icmp_seq=969 ttl=64 time=858 ms
64 bytes from 192.168.1.1: icmp_seq=970 ttl=64 time=886 ms
64 bytes from 192.168.1.1: icmp_seq=971 ttl=64 time=890 ms
64 bytes from 192.168.1.1: icmp_seq=972 ttl=64 time=888 ms
64 bytes from 192.168.1.1: icmp_seq=973 ttl=64 time=910 ms
64 bytes from 192.168.1.1: icmp_seq=974 ttl=64 time=915 ms
64 bytes from 192.168.1.1: icmp_seq=975 ttl=64 time=937 ms
64 bytes from 192.168.1.1: icmp_seq=976 ttl=64 time=933 ms
64 bytes from 192.168.1.1: icmp_seq=977 ttl=64 time=947 ms
ping: sendmsg: Network is unreachable
ping: sendmsg: Network is unreachable
ping: sendmsg: Network is unreachable
ping: sendmsg: Network is unreachable
ping: sendmsg: Network is unreachable
ping: sendmsg: Network is unreachable
64 bytes from 192.168.1.1: icmp_seq=985 ttl=64 time=1.09 ms
64 bytes from 192.168.1.1: icmp_seq=986 ttl=64 time=2.02 ms
64 bytes from 192.168.1.1: icmp_seq=987 ttl=64 time=3.37 ms
64 bytes from 192.168.1.1: icmp_seq=988 ttl=64 time=1.08 ms
64 bytes from 192.168.1.1: icmp_seq=989 ttl=64 time=2.87 ms
64 bytes from 192.168.1.1: icmp_seq=990 ttl=64 time=1.11 ms
64 bytes from 192.168.1.1: icmp_seq=991 ttl=64 time=1.39 ms
64 bytes from 192.168.1.1: icmp_seq=992 ttl=64 time=1.11 ms
64 bytes from 192.168.1.1: icmp_seq=993 ttl=64 time=1.10 ms

由于某些未知原因,有时我的 WiFi 连接变得非常慢,主要原因是 ping 时间。

我应该手动断开我的 WiFi 并重新连接。

我在 Ubuntu 20.04 LTS 上。

我想让它自动化。这是我想出的脚本片段。但我不能把它们放在一起:

# Read time using awk
ping 192.168.1.1 | awk '{gsub("time=", ""); print $7}'

# Disconnecting from WiFi
nmcli con down WiFiName

# Reconnecting to WiFi
nmcli device wifi connect

我试过这个,但它不起作用:

while read Line; do
    echo "read line"
    echo $Line
done <<< $(ping 192.168.1.1)

基本上,我坚持将ping标准输出重定向到 while 循环,并且坚持使用该awk命令聚合平均时间。

我怎样才能将它们结合在一起?

更新

对于任何对最终脚本感兴趣的人,请在下面查看我的答案。

networking
  • 2 个回答
  • 76 Views
Martin Hope
Saeed Neamati
Asked: 2021-10-12 04:08:14 +0800 CST

inotifywait 未检测到链接

  • 0

我已经成功地为目录中的修改创建了一个观察者,递归:

inotifywait -m -r -e modify --format '%w%f' "$Path" | while read File
do
    echo "File $File is modified"
done

但是,我在该目录中有一些符号链接。当我在编辑器中打开它们并更改它们时,inotifywait不会打印任何东西。

我认为这是因为实际文件位于另一个目录中。

我怎么知道inotifywait也检测链接的变化?

symbolic-link
  • 1 个回答
  • 424 Views
Martin Hope
Saeed Neamati
Asked: 2021-09-28 23:59:42 +0800 CST

envsubst 可以用来替换给定变量中的环境变量,而不是文件吗?

  • 0

我知道我可以使用envsubst命令来替换文件中的环境变量并将其写入输出文件:

envsubst < input.txt > output.txt

但是,现在我只有一个变量,它不是一个文件。但是我仍然需要替换其中的任何环境变量。

export original_text="Hello $name, please come here $date"
# I want to be able to replace $name and $date, in the RAM and not on disk and files
export $name="John"
export $date="tomorrow"
output=$(envsubst < $original_text) # this is a pseudo-command
echo $output
# prints => Hello John, please come here tomorrow

可能吗?怎么能做到这一点?

command-line
  • 1 个回答
  • 1629 Views
Martin Hope
Saeed Neamati
Asked: 2021-08-27 01:37:19 +0800 CST

为什么 shell 不能仅通过名称在当前目录中找到文件?

  • 4

我为 Ubuntu 下载了 VS Code 的.deb文件。我将其重命名为vs.deb.

然后我去我的下载目录:

cd ~/Downloads

现在我在这里,我尝试安装它:

sudo apt install vs.deb

这就是我得到的:

Reading package lists... Done   
Building dependency tree          
Reading state information... Done   
E: Unable to locate package vs.deb   
E: Couldn't find any package by glob 'vs.deb'

但是当我使用 安装它时./vs.deb,它会被安装:

sudo apt install ./vs.deb

为什么Linux不接受同一目录中的文件名而不需要相对路径?

command-line
  • 1 个回答
  • 1051 Views
Martin Hope
Saeed Neamati
Asked: 2021-08-17 03:15:25 +0800 CST

我的管道在我的 if 语句中不起作用

  • -2

我有这个脚本来检查git status我的所有存储库:


find / -type d -name .git 2>&- | 
while read gitFolder; do
    if [[ $gitFolder == *"/Temp/"* ]]; then
        continue;
    fi
    if [[ $gitFolder == *"/Trash/"* ]]; then
        continue;
    fi
    if [[ $gitFolder == *"/opt/"* ]]; then
        continue;
    fi
    parent=$(dirname $gitFolder);
    if [[ `git -C $parent status --porcelain` ]]; then
        echo "";
        echo $parent;
        git -C $parent status --porcelain
    else if [[ $(git -C $parent status | grep ahead) ]]; then
        echo "";
        echo "$parent is not pushed yet";
    fi
done 

但它不起作用。如果我删除第二个else-block,那么它可以工作。

基本上我想知道 git 存储库是否有任何更改(第一个 if)或者它是否在 master 之前(第二个 if)。

如果条件,我应该如何更改第二个?

bash
  • 2 个回答
  • 461 Views
Martin Hope
Saeed Neamati
Asked: 2021-07-17 23:06:48 +0800 CST

哪个终端文本编辑器使用类似 GUI 的键盘快捷键?

  • 4

我寻找一个编辑器,其中Ctrl+C复制、Ctrl+X剪切、Ctrl+V粘贴、Ctrl+Z撤消、Ctrl+Y重做、F3搜索和F2重命名。当我单击鼠标左键时,光标应该到那里。所有模式应同时处于活动状态(命令和插入和...)。

还Ctrl+W关闭选项卡式界面中的当前选项卡,Alt+F4关闭当前聚焦的应用程序,Ctrl+Tab猜测之间的选项卡,选项卡,Ctrl+调O出打开的对话框,Ctrl+P调出打印对话框,

有哪些 Linux 编辑器可以在终端中使用并具有这种行为?

command-line
  • 4 个回答
  • 1050 Views
Martin Hope
Saeed Neamati
Asked: 2021-06-24 23:39:18 +0800 CST

无法在我的 ubuntu 上安装 docker,因为 apt-get update 中出现“NO_PUBKEY 7EA0A9C3F273FCD8”错误

  • 0

我正在尝试在 Ubuntu 20.04 LTS 上安装 Docker。我正在使用官方文档。我以前做过,没有问题。

这是运行后的错误sudo apt-get update:

Hit:1 http://dl.google.com/linux/chrome/deb stable InRelease
Hit:2 http://packages.microsoft.com/repos/code stable InRelease                                                       
Get:3 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]                                             
Hit:4 http://ir.archive.ubuntu.com/ubuntu focal InRelease                   
Hit:5 http://ir.archive.ubuntu.com/ubuntu focal-updates InRelease              
Get:6 https://download.docker.com/linux/ubuntu focal InRelease [52.1 kB]       
Hit:7 http://ir.archive.ubuntu.com/ubuntu focal-backports InRelease                        
Err:6 https://download.docker.com/linux/ubuntu focal InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7EA0A9C3F273FCD8
Reading package lists... Done      
W: GPG error: https://download.docker.com/linux/ubuntu focal InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7EA0A9C3F273FCD8
E: The repository 'https://download.docker.com/linux/ubuntu focal InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

我看到了如何修复 GPG 错误“NO_PUBKEY”?但我无法解决问题。

apt
  • 1 个回答
  • 6969 Views
Martin Hope
Saeed Neamati
Asked: 2021-06-14 21:15:32 +0800 CST

如何在ubuntu中递归地重命名文件,使用grep和rename not find?

  • -2

关于如何重命名文件有无数的问题和答案。我是 Linux 新手,这无数种可能的方法、不同的结果和不同的配置让我感到困惑。

例如:

  • rename有效,但不是递归的
  • grep递归工作,但不能用于搜索文件和目录名称,而不是文件内容
  • find有效,但是当您想使用正则表达式进行搜索时,语法很长。

还有很多关于ask ubuntu和stackoverflow的答案对我不起作用,我不知道如何调试和解决它们。

所以,原谅我再问一次。

我正在寻找一种干净、易于记忆的方式:

使用简单的正则表达式递归地重命名文件。

我已经使用以下语法对文件内容进行了处理:

grep -rl search_regex | xargs sed -i 's/old/new/g'

它工作起来没有很多挫败感。它开箱即用。它只是工作。我正在寻找一个干净整洁的可行解决方案。你能帮我吗?

command-line
  • 3 个回答
  • 1111 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