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

alper's questions

Martin Hope
alper
Asked: 2023-10-03 04:48:51 +0800 CST

即使失败,如何每 N 秒连续运行 bash 脚本?

  • 5

我想每 N 秒运行一个 bash 脚本,即使它失败,我也希望while循环继续而不崩溃。

我正在使用以下解决方案如何每 N 秒重复运行 bash 脚本?:

同时脚本;睡 10 个小时;完毕

有评论说:This is the canonical way to repeat a command as long as it doesn't fail.. 如果我的脚本失败,我会观察到 while 循环被终止。


有没有办法try...catch在脚本上应用机制并继续循环,while即使脚本失败?

linux
  • 2 个回答
  • 52 Views
Martin Hope
alper
Asked: 2022-12-11 04:25:35 +0800 CST

如何将 else 用于 `ifne`?

  • 5

ifne- 如果标准输入不为空则运行命令

如果可能的话,如果标准输入也为空,我想运行命令;的其他部分ifne。

$ printf "hello" | ifne echo "world" 
world

如果标准输入为空,我想以不同的语句结束。

$ printf "" | ifne echo "world" || echo "else"但它什么都不打印。有可能else吗ifne?

bash
  • 4 个回答
  • 46 Views
Martin Hope
alper
Asked: 2022-09-30 12:11:54 +0800 CST

如何在 less 中禁用“v”键绑定?

  • 15

当我使用less并按下v它时,它会切换到当前设置的编辑器(Emacs 或 vim)。

MISCELLANEOUS COMMANDS
v    Edit the current file with $VISUAL or $EDITOR.

在我不希望在编辑器中打开当前文件的情况下,是否可以防止这种行为?

less
  • 2 个回答
  • 838 Views
Martin Hope
alper
Asked: 2022-05-08 09:25:15 +0800 CST

如何使用 `find` 查找文件并使用 awk 在文件中搜索?

  • 1

在一个文件夹及其子文件夹中,我想搜索一个模式。为此,我正在使用:grep+cut+awk+tr管道。

printf "I am so        wide alper world zorro the end\t\t\talper\n" > alper.txt
printf "zorro alper alper alper    skfjsdlkfj dslfj dslkj dslfkj sldk\n" > doo.tex
mkdir .git && printf "zorro zoo\n" > .git/test_file.tex
grep -Hrn -e "zorro" --exclude-dir='.git' --color=always -I -F . | \
    cut -c 11- | awk '$0="\033[33;35m"$0' | tr -s '[:space:]' |  ifne less -r

alper.txt:1:I am so wide alper world zorro the end        alper
doo.tex:1:zorro alper alper alper skfjsdlkfj dslfj dslkj dslfkj sldk

此处搜索到的模式 ( zorro) 以粗体红色显示。按以下顺序显示:

<filename>:<line_number>:<matching line>

如何使用此管道查找文件并使用 awk 在文件中搜索find?

awk text-processing
  • 1 个回答
  • 64 Views
Martin Hope
alper
Asked: 2022-05-08 01:12:15 +0800 CST

如何从“打开”的选项卡完成建议中抑制 *://?

  • 0

我OS X在zshshell中体验过这个,打开的手册页。

$ type open
open is /usr/bin/open

$ man open
  OPEN(1)                   General Commands
Manual                            OPEN(1)

NAME
     open – open files and directories

当我键入open并键入选项卡时,我看到以下输出:

$ open                                                                                                                          
file:      ftp://     gopher://    http://    https://

我从不尝试打开任何file:, ftp://, gopher://, http://, https://,因此我只想压制它们。是否可以抑制它们并且只看到文件/文件夹名称。

zsh autocomplete
  • 1 个回答
  • 25 Views
Martin Hope
alper
Asked: 2022-05-07 13:02:33 +0800 CST

如何在 grep 输出的文件名后添加空格?

  • -1

我正在使用grep搜索文件中的匹配模式,并从输出中复制其文件名。因为我经常做这个操作,所以我最终也可能会复制:。因此,是否可以在第一个匹配的半列或文件名的结尾之前添加两个空格?

$ grep -Hrn -e "zorro" --color=always --exclude-dir=dir -I -F . | \
    cut -c 11- | awk '$0="\033[33;35m"$0' | tr -s '[:space:]'
doo.tex:1:zorro alper alper alper skfjsdlkfj dslfj dslkj

想要的输出:

doo.tex  :1:zorro alper alper alper skfjsdlkfj dslfj dslkj
        ^
  <two space added>
grep sed
  • 2 个回答
  • 178 Views
Martin Hope
alper
Asked: 2022-04-30 10:19:53 +0800 CST

为什么要为 .z.* 文件创建

  • 0

在我的主文件夹中,我意识到创建了很多.z.*文件。他们都是空的。我不知道是哪个过程创建了它们。创建所有这些文件的原因可能是什么,删除它们是否安全?

$ cat .z.*
$ ls .z.*
.z.28    .z.3504  .z.6019  .z.9240   .z.12471  .z.15266  .z.18282  .z.20997  .z.24111  .z.26818  
.z.40    .z.3511  .z.6020  .z.9293   .z.12495  .z.15268  .z.18285  .z.21031  .z.24129  .z.26847  
.z.145   .z.3533  .z.6039  .z.9305   .z.12516  .z.15303  .z.18292  .z.21051  .z.24136  .z.26874  
.z.217   .z.3584  .z.6049  .z.9316   .z.12548  .z.15337  .z.18348  .z.21099  .z.24143  .z.26900  
.z.284   .z.3599  .z.6107  .z.9326   .z.12570  .z.15361  .z.18360  .z.21102  .z.24208  .z.26909  
.z.342   .z.3611  .z.6125  .z.9353   .z.12587  .z.15378  .z.18370  .z.21103  .z.24265  .z.26913  
.z.357   .z.3658  .z.6138  .z.9370   .z.12613  .z.15438  .z.18371  .z.21120  .z.24292  .z.26932  
.z.360   .z.3668  .z.6152  .z.9396   .z.12676  .z.15452  .z.18398  .z.21141  .z.24303  .z.27007  
.z.397   .z.3702  .z.6159  .z.9428   .z.12682  .z.15468  .z.18399  .z.21181  .z.24316  .z.27040  
.z.406   .z.3744  .z.6173  .z.9443   .z.12685  .z.15476  .z.18419  .z.21219  .z.24339  .z.27042  
.z.415   .z.3784  .z.6204  .z.9452   .z.12712  .z.15491  .z.18483  .z.21278  .z.24341  .z.27062  
.z.500   .z.3818  .z.6317  .z.9467   .z.12748  .z.15561  .z.18484  .z.21299  .z.24344  .z.27076  
.z.551   .z.3870  .z.6329  .z.9557   .z.12763  .z.15575  .z.18490  .z.21339  .z.24363  .z.27085  
.z.605   .z.3886  .z.6339  .z.9594   .z.12782  .z.15583  .z.18494  .z.21384  .z.24373  .z.27124  
.z.606   .z.3887  .z.6369  .z.9605   .z.12791  .z.15587  .z.18501  .z.21399  .z.24399  .z.27127 
files
  • 1 个回答
  • 52 Views
Martin Hope
alper
Asked: 2021-12-20 07:55:22 +0800 CST

如何从文件中检查 gpg 的密码?

  • 0

我想检查我user-id位于文件中的密码是否正确。我已将密码存储在一个文件 ( /home/user/.gpg_pass.txt) 中,而不是将其用作:

gpg --verbose --batch --yes --pinentry-mode loopback \
    --passphrase-file=/home/user/.gpg_pass.txt
    --decrypt <file>

在使用此命令之前,我想验证文件中的密码是否正确输入。我试过了,但没有帮助:

cat /home/user/.gpg_pass.txt | gpg --dry-run --passwd <key_id>


来自:man_gpg

--passwd user-id
       Change the passphrase of the secret key belonging to the certificate 
       specified as user-id.  This is a shortcut for the sub-command passwd  
       of  the edit  key  menu.  When using together with the option --dry-run 
       this will not actually change the passphrase but check that the current 
       passphrase is correct.

当我输入:

$ gpg --dry-run --passwd <key_id>

两次以下窗口显示我输入密码,(如果输入错误的密码,它会 Bad Passphrase (try 2 of 3)在 GUI 控制台中显示):

 ┌────────────────────────────────────────────────────────────────┐
 │ Please enter the passphrase to unlock the OpenPGP secret key:  │
 │ "Alper <[email protected]>"                                      │
 │ 3072-bit RSA key, ID 86B9E988681A51D1,                         │
 │ created 2021-12-15.                                            │
 │                                                                │
 │                                                                │
 │ Passphrase: __________________________________________________ │
 │                                                                │
 │         <OK>                                    <Cancel>       │
 └────────────────────────────────────────────────────────────────┘

与其在控制台内手动输入密码短语,不如将其作为管道输入,gpg --dry-run --passwd <key_id>并且可以返回其输出,验证给定密码短语是否正确?


相关:https ://stackoverflow.com/q/11381123/2402577

password pipe
  • 1 个回答
  • 1125 Views
Martin Hope
alper
Asked: 2021-11-18 03:05:24 +0800 CST

使用 `--xform` 时如何查看任何 tar 进度

  • 0

我具有以下功能以提取丢弃的目录结构。

tarx() {
    STRIP=${1%.*}  # strip last suffix
    NAME=${STRIP%.tar}  # strip .tar suffix, if present
    tar -xvf "$1" --xform="s|^|$NAME/|S"
}

$ tarx bone.n26c100.tbz2

在这里,我想在提取时查看进度条。

我努力了:

$ pv "$1" | tar -xvf "$1" --xform="s|^|$NAME/|S"
B 0:00:29 [0.00 B/s] [<=>

这没有显示进度变化。tar如果使用--xform=标志,我如何应用进度条。


相关:https ://superuser.com/questions/168749/is-there-a-way-to-see-any-tar-progress-per-file

tar
  • 1 个回答
  • 125 Views
Martin Hope
alper
Asked: 2019-12-10 00:34:11 +0800 CST

NTFS-3G 不能在 macOS catalina 上运行:MFTMirr 与 $MFT 不匹配(记录 3)

  • 0

我已将我的 macOS 从 High Sierra 升级到 Catalina,我认为这会导致我出现以下错误。有没有办法解决这个错误?

$ mkdir /Volumes/FOLDER
$ sudo /usr/local/bin/ntfs-3g /dev/disk2s1 /Volumes/FOLDER -olocal -oallow_other -o auto_xattr    
$MFTMirr does not match $MFT (record 3).
Failed to mount '/dev/disk2s1': Input/output error
NTFS is either inconsistent, or there is a hardware fault, or it's a
SoftRAID/FakeRAID hardware. In the first case run chkdsk /f on Windows
then reboot into Windows twice. The usage of the /f parameter is very
important! If the device is a SoftRAID/FakeRAID then first activate
it and mount a different device under the /dev/mapper/ directory, (e.g.
/dev/mapper/nvidia_eahaabcc1). Please see the 'dmraid' documentation
for more details.

请注意,我已遵循以下NTFS-3G 指南。

mount usb
  • 1 个回答
  • 223 Views
Martin Hope
alper
Asked: 2019-09-30 23:46:09 +0800 CST

如果目标位置是已安装的文件夹,rsync 是否会下载整个文件?

  • 0

我正在使用WebDAV客户端将ownCloud文件夹(或任何其他云的文件夹)作为驱动程序安装在本地计算机上

sudo apt-get install davfs2
mkdir oc
sudo mount.davfs https://b2drop.eudat.eu/remote.php/webdav/ oc

在这个场景中,假设我A.tar.gz在挂载的文件夹上有一个压缩文件 (),并且该文件被复制到我的本地目录中B.tar.gz。

稍后该文件在已安装的目录上更新,我只想将其更新的部分复制到我的本地目录rsync --no-whole-file oc/A.tar.gz /home/local/B.tar.gz,如果可能的话,不下载整个文件。

基于the rsync algorithm仅在 }A.tar.gz中未找到的部分,B.tar.gz加上少量用于校验和和块索引的数据} 应该通过源和目标之间的链接 } 发送。


在这种情况下,当我使用rsyncovermounted 文件夹时,在计算校验和期间,以便仅传输已修改的部分:

=> 是否rsync必须读取整个文件,这将导致将完整数据下载到已安装目录中,而不仅仅是其更新部分?


请注意,以下行对 rsync over sshfs 有一个很好的解释:Differences between rsync on remote and rsync local on mounted sshfs?

mount
  • 1 个回答
  • 308 Views
Martin Hope
alper
Asked: 2018-05-16 04:23:20 +0800 CST

rsync: --no-whole-file 如果将一行添加到文件的尾部则不起作用

  • 2

我的问题与为什么 rsync 不做增量传输问题有关。

首先,我创建一个 1GB 的文件并/target使用 rsync 传输到文件夹中。后来我doo在该文件的尾部添加了 s 字符串。当我将同一个文件传输到/target文件夹时,我观察到整个文件已被传输,而不是仅传输其更新的部分。

[Q]如何强制 rsync 只进行文件的更新部分的增量传输?有可能还是我唯一的选择是重新传输完整的文件?

例子:

$ mkdir target
$ fallocate -l 1G target/temp_1GB_file
$ rsync --inplace --no-whole-file  --size-only --progress temp_1GB_file doo
temp_10GB_file
  1073741824 100%  227.30MB/s    0:00:04 (xfer#1, to-check=0/1)

sent 131163 bytes  received 229425 bytes  48078.40 bytes/sec
total size is 1073741824  speedup is 2977.75

$ echo 'doo' >> temp_10GB_file
$ rsync --no-whole-file  --size-only --progress temp_1GB_file doo # Here complete file has been transferred all over again.
  temp_10GB_file
  1073741828 100%  226.44MB/s    0:00:04 (xfer#1, to-check=0/1)

sent 131171 bytes  received 229418 bytes  48078.53 bytes/sec
total size is 1073741828  speedup is 2977.74
rsync
  • 2 个回答
  • 3602 Views
Martin Hope
alper
Asked: 2018-05-02 01:45:54 +0800 CST

scp 将文件成功传输到主机但文件不会显示

  • 4

我正在尝试将文件从本地机器传输到远程机器。

当我scp不使用-v选项时,它只给出以下输出:

.--. or '\033[0;1;33;93m.-\033[0;1;32;92m-.\033[0m'

当我尝试scp使用-v选项时,我得到以下输出,似乎文件传输成功:

--

$ scp -v file.sh  user@IP:/home/user/foo

debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: pledge: network
debug1: Sending environment.
debug1: Sending env LC_PAPER = tr_TR.UTF-8
debug1: Sending env LC_ADDRESS = tr_TR.UTF-8
debug1: Sending env LC_MONETARY = tr_TR.UTF-8
debug1: Sending env LC_NUMERIC = tr_TR.UTF-8
debug1: Sending env LC_ALL = en_US.UTF-8
debug1: Sending env LC_TELEPHONE = tr_TR.UTF-8
debug1: Sending env LC_IDENTIFICATION = tr_TR.UTF-8
debug1: Sending env LANG = en_US.UTF-8
debug1: Sending env LC_MEASUREMENT = tr_TR.UTF-8
debug1: Sending env LC_CTYPE = UTF-8
debug1: Sending env LC_TIME = tr_TR.UTF-8
debug1: Sending env LC_NAME = tr_TR.UTF-8
debug1: Sending command: scp -v -t /home/user/foo
    .--.
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
Transferred: sent 2504, received 2668 bytes, in 1.7 seconds
Bytes per second: sent 1510.2, received 1609.1
debug1: Exit status 0

请在此处sshd_config查看文件。请注意,我可以进入远程机器。也返回。sshssh user@IP pwd/home/user

[Q] scp成功传输文件但它没有显示在远程机器上。这可能是什么原因,我该如何解决?

scp
  • 3 个回答
  • 10843 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