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

Prototype's questions

Martin Hope
Prototype
Asked: 2019-10-24 22:03:39 +0800 CST

如何在没有 ctrl+c 的情况下停止对 journalctl 日志文件的跟踪命令并将输出保存到文件中

  • 0

我正在运行以下命令并将输出保存到文件中:

sudo journalctl -u iotedge -f >> sub.txt

问题是,我必须用 ctrl+c 停止命令的操作,否则它不会返回到命令提示符。有什么方法可以停止跟随命令并将其输出保存到文件而不按 ctrl+c。

command-line bash systemd-journald
  • 1 个回答
  • 453 Views
Martin Hope
Prototype
Asked: 2019-10-10 22:54:32 +0800 CST

如何在 ubuntu 系统上查看 WinSCP 执行的活动

  • 0

我经常从 WinSCP 连接到 ubuntu 机器来执行一些文件操作,例如复制或删除文件。但是这些操作不会记录在 Ubuntu 系统的任何日志中(我不知道)。有什么方法可以记录这些操作以及执行这些操作的用户是谁。IP 地址和时间戳符号会更大。

ssh remote-access logs
  • 1 个回答
  • 258 Views
Martin Hope
Prototype
Asked: 2019-10-08 00:05:41 +0800 CST

如何在 ~/.bash_history 文件中查看时间

  • 7

我在~/.bashrc文件中添加了时间,所以现在它显示了我执行history如下命令的时间:

  376  04/10/19 20:39:52 sudo cat ~/.bash_history
  377  04/10/19 20:40:04 date
  378  07/10/19 10:13:29 echo 'HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bashrc
  379  07/10/19 10:13:38 source ~/.bashrc
  380  07/10/19 10:13:54 history
  381  07/10/19 10:20:08 sudo vim /home/subir/.bash_history 
  382  07/10/19 10:20:29 sudo nano /home/subir/.bash_history 
  383  07/10/19 11:34:20 cd ..
  384  07/10/19 11:34:34 find | grep .bash_history
  385  07/10/19 11:34:48 cat ./subir/.bash_history 
  386  07/10/19 11:37:32 history

但是当这个会话的数据被附加到~/.bash_history文件时,它会显示如下内容:

#1570201804
date
#1570423409
echo 'HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bashrc
#1570423418
source ~/.bashrc
#1570423434
history
#1570423808
sudo vim /home/subir/.bash_history 
#1570423829
sudo nano /home/subir/.bash_history 

之后的值是什么#?谁能帮我推断它的含义或告诉我一种在~/.bash_history文件中获取时间戳的方法。

gnome-terminal bash history bash-history
  • 2 个回答
  • 3547 Views
Martin Hope
Prototype
Asked: 2019-10-04 19:53:49 +0800 CST

使用 grep 和 sed 更改 config.yaml 文件

  • 2

我有一个 config.yaml 文件,我想使用 bash 脚本对其进行编辑或更改。所以我得到了一个使用 grep 和 sed 的命令,它给了我想要的更改,但问题是当我应用 sed 时,它会应用于整个文件,包括我要编辑的部分。以下是编辑前的文件部分:

    ###############################################################################
29  
30  # Manual provisioning configuration
31  # provisioning:
32  #  source: "manual"
33  #  device_connection_string: ""
34  
35  # DPS TPM provisioning configuration
36  # provisioning:
37  #   source: "dps"
38  #   global_endpoint: "https://global.azure-devices-provisioning.net"
39  #   scope_id: "{scope_id}"
40  #   attestation:
41  #     method: "tpm"
42  #     registration_id: "{registration_id}"
43  
44  # DPS symmetric key provisioning configuration
45  # provisioning:
46  #   source: "dps"
47  #   global_endpoint: "https://global.azure-devices-provisioning.net"
48  #   scope_id: "{scope_id}"
49  #   attestation:
50  #     method: "symmetric_key"
51  #     registration_id: "{registration_id}"
52  #     symmetric_key: "{symmetric_key}"
53  
54  ###############################################################################

现在我想在第 42 行从“#DPS TPM 配置配置”编辑到“#registration_id:“{registration_id}””。所以我使用以下命令:

grep -Pzom 1 "# DPS TPM provisioning configuration(.|\n)*?(?=\n# DPS)" config.yaml | sed 's/^#[ \t]//' config.yaml

这给了我以下输出:


Manual provisioning configuration
provisioning:
  source: "manual"
  device_connection_string: ""

DPS TPM provisioning configuration
provisioning:
  source: "dps"
  global_endpoint: "https://global.azure-devices-provisioning.net"
  scope_id: "{scope_id}"
  attestation:
    method: "tpm"
    registration_id: "{registration_id}"

DPS symmetric key provisioning configuration
provisioning:
  source: "dps"
  global_endpoint: "https://global.azure-devices-provisioning.net"
  scope_id: "{scope_id}"
  attestation:
    method: "symmetric_key"
    registration_id: "{registration_id}"
    symmetric_key: "{symmetric_key}"

###############################################################################

这会编辑所需的部分,但也会编辑整个文件。我只想将 sed 应用于文件的 grep 输出,而不是整个文件。任何人都可以帮助命令!

command-line bash sed grep
  • 1 个回答
  • 6189 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