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

Saeed Neamati's questions

Martin Hope
Saeed Neamati
Asked: 2023-12-11 21:03:17 +0800 CST

如何将文字值(任意值)添加到 grep -Ff

  • 3

我使用此代码来过滤命令的结果find:

grep -Ff /path/to/file

现在,我想向该grep命令添加任意值。

换句话说,我想说,嘿 grep,使用固定模式,并从该文件加载您的模式,这里是这些不在该文件中的静态模式。

我怎样才能做到这一点?

PS上下文:我问我可以根据另一个文件的行过滤掉查找结果吗?,现在我想根据文件中的条目Dependencies或者它们是否为Infra或来过滤查找结果Base。但我无法将Infra和添加Base到Dependencies文件中。该文件仅适用于模块。

grep
  • 2 个回答
  • 44 Views
Martin Hope
Saeed Neamati
Asked: 2022-12-05 03:49:13 +0800 CST

如何告诉 ps 为 cmd 使用更多空间?[复制]

  • 5
这个问题在这里已经有了答案:
增加 ps -o 列宽 (2 个答案)
2 天前关闭。

我正在使用此命令查看我的顶级进程:

ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head -10

但是,它的 CMD 列切断了路径。例如我看到这个结果:

    PID    PPID CMD                         %MEM %CPU
 583875  583874 node /Company/Projects/A  7.4  6.2
   1597    1594 node /Company/Projects/A  7.4  0.3
 585721  585720 node /Company/Projects/A  6.5  3.4
   2549    2548 node /Company/Projects/A  6.1  0.1
  51143   51142 node /Company/Projects/A  5.1  0.0
 210960  210959 node /Company/Projects/A  4.3  0.0
  40609   40608 node /Company/Projects/A  4.0  0.0
   2188    2187 node /Company/Projects/A  3.3  0.0
  42198   42197 node /Company/Projects/A  3.1  0.0

我无法区分进程。

如何增加该CMD列的长度?

ps
  • 1 个回答
  • 23 Views
Martin Hope
Saeed Neamati
Asked: 2022-11-13 01:00:42 +0800 CST

坚持使用 SSH 在远程 Debian 11 bullseye 上安装 Google Chrome

  • 6

我正在尝试在我拥有的 VPS 上安装 Google Chrome。

VPS 有Debian GNU/Linux 11 (bullseye)它。

我ssh root@ip用来连接。我运行这些命令:

apt-get update 
apt upgrade
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -O chrome
dpkg -i chrome

但我看到这些错误:

(Reading database ... 73725 files and directories currently installed.)
Preparing to unpack chrome ...
Unpacking google-chrome-stable (107.0.5304.110-1) over (107.0.5304.110-1) ...
dpkg: dependency problems prevent configuration of google-chrome-stable:
 google-chrome-stable depends on fonts-liberation; however:
  Package fonts-liberation is not installed.
 google-chrome-stable depends on libnspr4 (>= 2:4.9-2~); however:
  Package libnspr4 is not installed.
 google-chrome-stable depends on libnss3 (>= 2:3.26); however:
  Package libnss3 is not installed.
 google-chrome-stable depends on xdg-utils (>= 1.0.2); however:
  Package xdg-utils is not installed.

dpkg: error processing package google-chrome-stable (--install):
 dependency problems - leaving unconfigured
Processing triggers for mailcap (3.69) ...
Processing triggers for man-db (2.9.4-2) ...
Errors were encountered while processing:
 google-chrome-stable

当我尝试安装时,fonts-liberation我看到了这些错误:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 google-chrome-stable : Depends: libnspr4 (>= 2:4.9-2~) but it is not going to be installed
                        Depends: libnss3 (>= 2:3.26) but it is not going to be installed
                        Depends: xdg-utils (>= 1.0.2) but it is not going to be installed
                        Recommends: libu2f-udev but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

我没有尝试--fix-broken,因为我害怕破坏这个 VPS 上的东西。

如何在 Debian 11 bullseye 上安全地安装 Google Chrome?

更新 这是输出apt policy:

root@3rag:~# apt policy
Package files:
 100 /var/lib/dpkg/status
     release a=now
 500 https://download.docker.com/linux/debian bullseye/stable amd64 Packages
     release o=Docker,a=bullseye,l=Docker CE,c=stable,b=amd64
     origin download.docker.com
 500 http://security.debian.org/debian-security bullseye-security/main amd64 Packages
     release v=11,o=Debian,a=stable-security,n=bullseye-security,l=Debian-Security,c=main,b=amd64
     origin security.debian.org
 500 http://debian.mirror.serveriai.lt/debian bullseye/non-free amd64 Packages
     release v=11.5,o=Debian,a=stable,n=bullseye,l=Debian,c=non-free,b=amd64
     origin debian.mirror.serveriai.lt
 500 http://debian.mirror.serveriai.lt/debian bullseye/contrib amd64 Packages
     release v=11.5,o=Debian,a=stable,n=bullseye,l=Debian,c=contrib,b=amd64
     origin debian.mirror.serveriai.lt
 500 http://debian.mirror.serveriai.lt/debian bullseye/main amd64 Packages
     release v=11.5,o=Debian,a=stable,n=bullseye,l=Debian,c=main,b=amd64
     origin debian.mirror.serveriai.lt
Pinned packages:
root@3rag:~# 
debian
  • 2 个回答
  • 51 Views
Martin Hope
Saeed Neamati
Asked: 2022-09-11 03:18:07 +0800 CST

是否可以捆绑子外壳输出?

  • 3

我有这段代码来检查我所有的 git 文件夹的状态。

find / -maxdepth 3 -not -path / -path '/[[:upper:]]*' -type d -name .git -not -path "*/Trash/*" -not -path "*/Temp/*" -not -path "*/opt/*" -print 2>/dev/null |
{
    while read gitFolder; do
        (
            parent=$(dirname $gitFolder);
            Status=$(git -C $parent status)
            if [[ $Status == *Changes* ]]; then
                echo $parent;
                git -C $parent status --porcelain
                echo ""
            elif [[ $Status == *ahead* ]]; then
                echo "Push $parent";
                echo
            elif [[ $Status == *diverged* ]]; then
                echo "Sync $parent";
                echo
            fi
        ) &
    done
    wait
}

当我按顺序运行它时,我在终端中得到了一个很好的可读打印。但是速度越来越慢。当我并行运行它(使用&)时,我得到了很好的速度,但输出变得一团糟。

是否可以以某种方式锁定每个内壳的输出并将每个内壳的标准输出打印在一个块中?

bash shell
  • 1 个回答
  • 40 Views
Martin Hope
Saeed Neamati
Asked: 2022-07-05 21:28:51 +0800 CST

查找具有名称的目录,但如果它们包含特定的顶级文件,则对其进行过滤

  • 4

我想找到所有命名的目录,Contents然后从找到的结果列表中,我想过滤它们,只包括那些Database.json直接在其中命名的文件。

find / -type d -name Contents 2>/dev/null |
while read dir;
do
    if [ -f $dir/Database.json ]; then
        echo $dir
    fi
done

此代码有效。但我认为这是矫枉过正。我认为应该有一个更简单的方法来做到这一点。

我可以重写这段代码以变得更简单吗?

bash shell
  • 1 个回答
  • 197 Views
Martin Hope
Saeed Neamati
Asked: 2022-07-01 05:38:58 +0800 CST

如何使用 jo 从 shell 中的关联数组创建 JSON 对象?

  • 1

我知道如何从关联数组创建 JSON,但这不是我的问题。

我有这个关联数组:

declare -A aliases
aliases[Index]=components/Index/Exports
aliases[Shared]=components/Shared/Exports
aliases[Icons]=components/Icons/Exports

现在我需要将这个关联数组转换成这个 JSON:

{
    "compilerOptions": {
        "baseUrl": ".",
        "paths": {
            "Index": ["components/Index/Exports"],
            "Shared": ["components/Shared/Exports"],
            "Icons": ["components/Icons/Exports"],
        }
    }
}

我想使用jo和jq。但我想不出嵌套。

我试过这段代码:

jo -p compilerOptions[baseUrl]=. compilerOptions[paths]="$(jo -p a ${Aliases[@]})"

但它甚至不运行。

bash json
  • 2 个回答
  • 144 Views
Martin Hope
Saeed Neamati
Asked: 2022-05-22 02:19:29 +0800 CST

如何保留传递给函数的参数扩展?

  • 1

我有这个功能:

cyan=`tput setaf 6`
reset=`tput sgr0`
function Info()
{
    echo "${cyan}$1${reset}"
}

我在其他脚本中使用它,就像Info some message.

但是,当我使用它来打印数组的所有项时,它只打印第一项:

Info "${ArrayVariable[@]}" # this only prints the first item

echo ${ArrayVariable[@]}" # this prints all of them

使用此语法和此函数时,如何保留所有变量?

bash function
  • 1 个回答
  • 114 Views
Martin Hope
Saeed Neamati
Asked: 2022-01-28 08:53:56 +0800 CST

为什么在所有子shell之后不执行此脚本中的等待?

  • 7

在这个脚本中,它会拉取所有 git 存储库:

#!/bin/bash

find / -type d -name .git 2>/dev/null | 
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);
    echo "";
    echo $parent;
    (git -C $parent pull && echo "Got $parent") &
done 
wait
echo "Got all"

不wait等待所有git pull子shell。

为什么会这样,我该如何解决?

subshell wait
  • 1 个回答
  • 506 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