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
    • 最新
    • 标签
主页 / unix / 问题

问题[text](unix)

Martin Hope
Ar Rakin
Asked: 2022-03-05 04:37:44 +0800 CST

如何在 n 行之后对文件内容进行排序?

  • 0

在 linux 中,我们可以运行sort命令对文件内容进行排序,但在我的情况下,我有以下文件(THANKS.txt):

These people have contributed to OSN Envoy. We always try to keep this list updated and correct. 
If you notice that your name is not listed here, then feel free to contact us.

Ar Rakin
Peter Williamson
David Brook
Bill Natt

此文件包含软件项目的贡献者列表。

我只想使用sort命令按字母顺序对名称进行排序,有什么想法吗?

sort text
  • 3 个回答
  • 146 Views
Martin Hope
Dingo
Asked: 2021-12-09 16:53:28 +0800 CST

任何文本实用程序或破解省略某些数字的诗行编号?

  • 0

我的目标是尝试查看 linux 中是否有常见的文本实用程序可以用来对诗歌的行数进行编号,如下所示:

OF Mans First Disobedience, and the Fruit
Of that Forbidden Tree, whose mortal tast
Brought Death into the World, and all our woe,
With loss of Eden, till one greater Man
Restore us, and regain the blissful Seat,
Sing Heav'nly Muse, that on the secret top
Of Oreb, or of Sinai, didst inspire
That Shepherd, who first taught the chosen Seed,
In the Beginning how the Heav'ns and Earth
Rose out of Chaos: or if Sion Hill
Delight thee more, and Siloa's brook that flow'd
Fast by the Oracle of God; I thence
Invoke thy aid to my adventrous Song,
That with no middle flight intends to soar
Above th' Aonian Mount, while it pursues
Things unattempted yet in Prose or Rhime.
And chiefly Thou, O Spirit, that dost prefer
Before all Temples th' upright heart and pure,
Instruct me, for Thou know'st; Thou from the first
Wast present, and with mighty wings outspread
Dove-like satst brooding on the vast Abyss
And mad'st it pregnant: What in me is dark
Illumin, what is low raise and support;
That to the highth of this great Argument
I may assert Eternal Providence,
And justifie the wayes of God to men.

获得这个:

        OF Mans First Disobedience, and the Fruit
        Of that Forbidden Tree, whose mortal tast
        Brought Death into the World, and all our woe,
     4  With loss of Eden, till one greater Man
        Restore us, and regain the blissful Seat,
        Sing Heav'nly Muse, that on the secret top
        Of Oreb, or of Sinai, didst inspire
     8  That Shepherd, who first taught the chosen Seed,
        In the Beginning how the Heav'ns and Earth
        Rose out of Chaos: or if Sion Hill
        Delight thee more, and Siloa's brook that flow'd
    12  Fast by the Oracle of God; I thence
        Invoke thy aid to my adventrous Song,
        That with no middle flight intends to soar
        Above th' Aonian Mount, while it pursues
    16  Things unattempted yet in Prose or Rhime.
        And chiefly Thou, O Spirit, that dost prefer
        Before all Temples th' upright heart and pure,
        Instruct me, for Thou know'st; Thou from the first
    20  Wast present, and with mighty wings outspread
        Dove-like satst brooding on the vast Abyss
        And mad'st it pregnant: What in me is dark
        Illumin, what is low raise and support;
    24  That to the highth of this great Argument
        I may assert Eternal Providence,
        And justifie the wayes of God to men.

可以,awk,也可以用这种方式缩进行

          OF Mans First Disobedience, and the Fruit
        Of that Forbidden Tree, whose mortal tast
          Brought Death into the World, and all our woe,
     4  With loss of Eden, till one greater Man
          Restore us, and regain the blissful Seat,
        Sing Heav'nly Muse, that on the secret top
          Of Oreb, or of Sinai, didst inspire
     8  That Shepherd, who first taught the chosen Seed,

还有这样的吗?

        OF Mans First Disobedience, and the Fruit
          Of that Forbidden Tree, whose mortal tast
        Brought Death into the World, and all our woe,
     4    With loss of Eden, till one greater Man
        Restore us, and regain the blissful Seat,
          Sing Heav'nly Muse, that on the secret top
        Of Oreb, or of Sinai, didst inspire
     8    That Shepherd, who first taught the chosen Seed,
utilities text
  • 2 个回答
  • 291 Views
Martin Hope
cipricus
Asked: 2021-10-20 06:23:04 +0800 CST

Dolphin 服务菜单中的 `kate -n new.txt %u` 可提升一级

  • 1

当创建一个新的 Dolphin 服务菜单以使用 Kate 创建一个新的文本文件时(假设没有文件夹的快捷方式,并且菜单选项在多次点击下相当隐藏,如此处所述),使用这样的桌面文件

[Desktop Entry]
Type=Service
Icon=kate
Actions=new-file
ServiceTypes=KonqPopupMenu/Plugin,inode/directory
X-KDE-Priority=TopLevel

[Desktop Action new-file]
Name=New text file
Icon=kate
Exec=kate %u

Kate 不在所选目录中创建文件,而是在与该目录相同的路径中创建文件,比预期高一级:选择文件夹/PATH/TO/MY_DIRECTORY并使用上下文菜单服务,文本文件已准备好保存在/PATH/TO而不是/PATH/TO/MY_DIRECTORY.

Exec=kate -n new.txt %u在创建和保存文件时,也会发生同样的情况。

如何让 Kate 保存或提议保存在所选目录中?

如何在所选文件夹中执行此操作?

text dolphin
  • 1 个回答
  • 55 Views
Martin Hope
Fabio
Asked: 2021-09-25 04:39:21 +0800 CST

使用 Kate 文本编辑器,如何比较两个文件并找出差异

  • 3

我正在使用 Kate 文本编辑器,我想比较两个文件,并找出(突出显示)它们的差异。也许有一个插件可以做到这一点?除了使用 Kate 之外,我对其他解决方案持开放态度,例如 shell 脚本,但我想以某种方式将它与 Kate 集成。

text-processing text
  • 1 个回答
  • 3679 Views
Martin Hope
George Thompson
Asked: 2019-06-07 00:49:05 +0800 CST

“tail”正在返回错误的请求数行

  • 0

我正在尝试使用以下方法对手册的输出进行子集化:

man dig | nl | tail -n +389 | head -n 6

但是,输出从第 304 行开始,而不是第 389 行。做一些研究,似乎标记为“#####################”的行不计算在内。这非常令人恼火,我目前的一本书正在使用这种方法来子集数行。

有什么解决方案可以修复被忽略的线条吗?

tail text
  • 1 个回答
  • 275 Views
Martin Hope
silver
Asked: 2019-03-18 09:05:23 +0800 CST

按某些条件导出文本文件

  • 0

我有超过 10000 行的 in.txt 文件,此文件中的一些文本在括号之间(此文本)和括号外的文本不导出,我想将 () 之间的所有文本导出到 out.txt,但前提是在如果超过 140 个字母的字母不导出,则为 140 个字母,并且每个文本都以新行 out.txt 导出。我不想在 ubuntu 中编写脚本,以及用非拉丁字母 (utf-8) 编写的文本。问候

ubuntu text
  • 1 个回答
  • 74 Views
Martin Hope
neverMind9
Asked: 2018-11-25 08:36:19 +0800 CST

屏幕上现有的命令行文本文件?(非图形 Linux)

  • 9

在 tty2 上,如何截取命令行的文本截图?

command-line text
  • 3 个回答
  • 822 Views
Martin Hope
Thomas Richter
Asked: 2018-11-16 02:11:11 +0800 CST

我怎样才能打乱一个文本文件表,一个表

  • -2

我有一张桌子。不得更改列顺序。并且应该保留这些值。

Name    Age size    Code
Abel    10  S   A
Bjorn   20  M   B
Casimir 30  L   C
Dennis  40  XL  D

我不只是想洗牌,而是独立地洗牌。所以作为示例输出:

Name    Age size    Code
Casimir 20  M   D
Dennis  10  L   C
Bjorn   40  XL  A
Abel    30  S   B

所以 shuf 不起作用。

shell text
  • 1 个回答
  • 494 Views
Martin Hope
Kumar
Asked: 2018-11-04 08:43:58 +0800 CST

Unix 文本处理

  • 2

2个文本文件。我必须从 2 个文本文件中找到 uniq 值,并使用文件名和 uniq 值在第三个文件中获取输出。例如 a.txt

1
4
3

b.txt

2
1
7

输出

File.out
b.txt 2
a.txt 3
a.txt 4
b.txt 7

我尝试了以下命令

cat a.txt b.txt | sort | uniq -u >>file.out

但它只打印值,不获取文件名

text-processing text
  • 1 个回答
  • 86 Views
Martin Hope
Ryan Ward
Asked: 2018-10-03 11:03:15 +0800 CST

如何将文档中的“动画”文本转换为静态文本?[复制]

  • 0
这个问题在这里已经有了答案:
如何正确记录频繁更新屏幕“部分”的控制台程序的输出,从而导致日志文件混乱? (2 个回答)
4年前关闭。

当我分析我在 GitHub 上获得的 Racon 的输出时,它具有动态“动画”文本作为 STDERR 的输出。

例如,当我 cat 文件时,它看起来像这样:

[racon::Polisher::initialize] 对齐重叠 624/2265116

然后文本“动画化”并覆盖自身以说出下一个数字:

[racon::Polisher::initialize] 对齐重叠 1954/2265116

最终结果是 7 行存储了 220 兆字节的数据。

我想单独列出这些步骤中的每一个,但是当我使用任何文本编辑器分析文本时,它会崩溃。

我唯一可用的工具是命令行工具。

command-line text
  • 2 个回答
  • 51 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