小编too*_*ley的帖子

生成非常大文件的二维码?

我想生成我的 4096 位装甲GPG私钥的二维码。关键是如此之大,程序似乎因为它的大小而失败。qrencode

$ gpg --export-secret-keys --armor > ~/private.key
$ ./qrencode -o test.png < ~/private.key
Run Code Online (Sandbox Code Playgroud)

结果:

无法对输入数据进行编码:数值结果超出范围

我怎样才能做到这一点?是否有可以处理非常大的 GPG 密钥的 qrencode 替代程序?我想按照这个 security.SE 问题的建议将其打印在纸上。


@geruetzel 和 @cuonglm 的评论正在解决我的问题的这个版本

bash gpg qr-code

8
推荐指数
2
解决办法
8343
查看次数

脚本无法写入 systemd 日志

简而言之:我想systemd用脚本写日记。

printf "%s\n%s\n%s\n" CODE_FILE=/etc/zsh/zprofile CODE_LINE=31 MESSAGE="could not read /etc/dircolors" | logger --journald 
Run Code Online (Sandbox Code Playgroud)

不起作用。当我执行那个确切的代码(或任何其他带有打印等的变体)时,日志 ( journalctl --full --all --no-pager -n 10) 中什么也没有发生。

这里有什么问题?

scripting bash systemd systemd-journald

7
推荐指数
1
解决办法
6630
查看次数

为什么 stdbool.h 中 true 和 false 的定义与 UNIX 程序的 true 和 false 完全相反?

stdbool.h 通常定义为:

#define false   0
#define true    1
Run Code Online (Sandbox Code Playgroud)

(来源:OpenBSDmusl等)

而 unix 程序false- 只有一个不成功的状态代码,被定义为:

int
main(int argc, char *argv[])
{
    return (1);
}
Run Code Online (Sandbox Code Playgroud)

为完整起见,unix 程序的定义true是:

int
main(int argc, char *argv[])
{
    return (0);
}
Run Code Online (Sandbox Code Playgroud)

很明显,它与falsestdbool.h中的值完全相反。我使用了OpenBSD的版本,因为 coreutils 的版本更冗长

使这些不同的历史原因是什么?

c history historical-unix exit-status

5
推荐指数
2
解决办法
416
查看次数

如何打印出包含特定字符串的任何函数的完整函数声明?

我的 中有很多函数bashrc,但是对于新创建的函数,我经常忘记函数的名称。

例如,当我在我的中定义了这个函数时.bashrc

function gitignore-unstaged
{
    ### Description:
    # creates a gitignore file with every file currently not staged/commited.
    # (except the gitingore file itself)
    ### Args: -

    git ls-files --others | grep --invert-match '.gitignore' > ./.gitignore

}
Run Code Online (Sandbox Code Playgroud)

我想要另一个函数来打印函数的定义,如:

$ grepfunctions "gitignore"
function gitignore-unstaged
{
    ### Description:
    # creates a gitignore file with every file currently not staged/commited.
    # (except the gitingore file itself)
    ### Args: -

    git ls-files --others | grep --invert-match '.gitignore' > ./.gitignore …
Run Code Online (Sandbox Code Playgroud)

bash shell-script text-processing function

4
推荐指数
1
解决办法
86
查看次数

用于为“dict”的命令行输出着色的工具?

是否有现有的解决方案可以对dict的输出进行着色以提高其可读性?我知道我可以使用手动为输出着色tput,但我希望有更好的解决方案。

(我不想在 GUI 中使用它)

shell colors

2
推荐指数
1
解决办法
392
查看次数

csv 文件和 awk:如果第一列匹配,则更改第二列条目,然后打印完整文件

我正在编写自己的密码管理器,我希望它严格符合 POSIX 标准。为了简化:我有这个文件,file.csv

mastodon;password2
bla;test
test;test
posteo;tewtasdwqrr
Run Code Online (Sandbox Code Playgroud)

基本上,我想要一个带有两个参数的函数:它应该从第一列和该行中选择第一个参数,它应该用第二个参数替换第二列条目。

例如:f "bla" "etewtw"将最后一个条目的密码更改为etewtw.

我尝试使用 awk,它也有一定效果:

awk -F ";" -v acc="bla" -v newpw="etewtw" \
'$1 ~ acc { $2=newpw; print $1";"$2 } END {print;} ' file.csv
Run Code Online (Sandbox Code Playgroud)

基本上,newpw如果第一列与acc参数匹配,我尝试将第二列设置为参数。更改流后,我想打印完整的流,这不起作用。以上显然不是正确的解决方案,但我不知道如何解决。

输出是:

bla;etewtw
posteo;tewtasdwqrr
Run Code Online (Sandbox Code Playgroud)

所以还挺成功的,条目被改了(至少在流中,但实际上改文件并不困难)。

但是,会出现两个问题:

  1. 输出中缺少条目。即mastodon;password2test;test。我希望那些 a) 保持在同一条线上,b) 保持不变。

  2. 如果我想改变最后一行,总是错误的。例如,如果我awk -F ";" -v acc="posteo" -v newpw="test" '$1 ~ acc { $2=newpw; print $1";"$2 } END {print;} '改为使用,结果是:

posteo;test
posteo test …
Run Code Online (Sandbox Code Playgroud)

awk text-processing posix

2
推荐指数
1
解决办法
183
查看次数

如何知道网络摄像机地址

我有带有静态 ip 地址预设的 ip 摄像头。我怎么知道它的ip使用linux?

我将相机直接连接到我的笔记本电脑。

我的系统是
Linux machine 3.5.7-gentoo #2 SMP

ifconfig eth0  
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  
        inet6 fe80::21e:ecff:fe18:854f  prefixlen 64  scopeid 0x20<link>  
        ether 00:1e:ec:18:85:4f  txqueuelen 1000  (Ethernet)  
        RX packets 35839  bytes 2150340 (2.0 MiB)  
        RX errors 0  dropped 0  overruns 0  frame 0  
        TX packets 1084  bytes 145354 (141.9 KiB)  
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0  
Run Code Online (Sandbox Code Playgroud)

linux networking ip

1
推荐指数
1
解决办法
2万
查看次数