使用 coreutils sort,如何按十六进制值(字段)进行数字排序?我期待着类似的东西
sort -k3,3x file_to_sort
Run Code Online (Sandbox Code Playgroud)
然而,这样的x情况并不存在。
编辑:到目前为止我想出的最佳解决方案是:
{ echo ibase=16; cut -d' ' -f3 file_to_sort; } |
bc | paste -d: - file_to_sort | sort -t: -k1,1n | cut -d: -f2-
Run Code Online (Sandbox Code Playgroud)
其中cut -d' ' -f3隔离搜索字段(这是-k3,3-这可能会有所不同,当然),和bc不转换为十进制(需要大写十六进制,没有0x前缀,匹配我的情况)。然后我加入、排序和拆分列。
最小样本输入:
5 hhf 25
3 ezh ae
1 hdh d12
2 ukr 9f
4 jjk 7
Run Code Online (Sandbox Code Playgroud)
预期输出(按hex第三列排序的文件):
4 jjk 7
5 hhf 25
2 ukr 9f
3 ezh ae
1 hdh …Run Code Online (Sandbox Code Playgroud) 使用^W(unix-word-rubout) 我可以轻松地从 bash shell 的当前命令中删除单个“单词”。
但是,当处理包含空格的引用参数(或包含反斜杠转义空格的未引用参数)时,这不会很好地工作,因为它只删除一个单词而不是整个参数。
所以我正在寻找一种删除整个论点的方法。
示例(光标总是在最后):
$ foo --bar "foo bar" meow
[black magic]
$ foo --bar "foo bar"
[black magic]
$ foo --bar
[black magic]
$ foo
Run Code Online (Sandbox Code Playgroud) 我试图仅打印 json 中的某些值(每个子对象一行),并在每一行上重复顶部对象中的一个值。
[
{
"name": "level1Name",
"lv1id": "id1",
"requests": [
{
"lv2id": "id2",
"name": "lvl2requestA",
"startDate": "2019-02-05 08:52:33.663+0000",
"requestState": "Succeeded"
},
{
"lv2id": "id2",
"name": "lvl2requestB",
"startDate": "2019-02-05 08:52:33.421+0000",
"requestState": "Succeeded"
}
]
},
{
"name": "level1Name",
"lv1id": "id12",
"requests": [
{
"lv2id": "id2",
"name": "lvl2requestD",
"startDate": "2019-02-05 08:52:19.823+0000",
"requestState": "Succeeded"
},
{
"lv2id": "id2",
"name": "lvl2requestA",
"startDate": "2019-02-05 08:52:19.689+0000",
"requestState": "Succeeded"
}
]
}
]
Run Code Online (Sandbox Code Playgroud)
["id1","2019-02-05 08:52:33.663+0000","lvl2requestA","Succeeded"]
["id1","2019-02-05 08:52:33.421+0000","lvl2requestB","Succeeded"]
["id12","2019-02-05 08:52:19.823+0000","lvl2requestD","Succeeded"]
["id12","2019-02-05 08:52:19.689+0000","lvl2requestA","Succeeded"]
Run Code Online (Sandbox Code Playgroud)
我已经尝试了几次尝试(例如使用变量/符号绑定运算符)。欢迎任何线索。
我可以同时输出stdout和stderr控制台屏幕和存储他们中的一个上到日志文件?
我写了一个测试shell脚本:
#!/bin/sh
echo OUT! >&1
echo ERR! >&2
Run Code Online (Sandbox Code Playgroud)
我可以通过运行脚本在屏幕上输出它们:
$./test
OUT!
ERR!
Run Code Online (Sandbox Code Playgroud)
我可以通过以下方式输出stderr并捕获stdout到日志文件中:
$./test | tee 1>log
ERR!
$cat log
OUT!
Run Code Online (Sandbox Code Playgroud)
我只能通过以下方式输出所有内容stdout并stderro输入日志文件:
$./test 2>&1| tee 1>log
$cat log
OUT!
ERR!
Run Code Online (Sandbox Code Playgroud)
我可以通过以下方式输出stdout和stderr并将它们全部捕获到日志文件中:
$./test 2>&1 | tee log
OUT!
ERR!
$cat log
OUT!
ERR!
Run Code Online (Sandbox Code Playgroud)
我可以通过以下方式输出两者都可以捕获stdout到日志文件中:
$./test | tee 2>&1 log
ERR!
OUT!
$cat log
OUT!
Run Code Online (Sandbox Code Playgroud)
我的问题是:
stdout并捕获stderr到文件中?(我试过./test|tee 2>log …这真是一团糟。当我们期望 Perl 使用s///类似 sed 的语法重命名时,当有大量不同的 实现rename,并且大多数情况下是 Perl 的不同版本rename.ul(二进制)时,我如何知道使用哪个命令?
我有一个场景,我想创建一个如下所示的文件夹结构。我怎样才能for以这种方式编写一个循环来创建这个结构:
ABC [Parent folder]
-> A1 [child folder]
-> B1 [child folder]
-> C1 [child folder]
-> W1 [child folder]
-> W2 [child folder]
-> W3 [child folder]
-> V1 [child folder]
-> V2 [child folder]
-> V3 [child folder]
Run Code Online (Sandbox Code Playgroud)
我将传入这样的文件:
ABC|A1|B1|C1
ABC|W1|W2|W3
ABC|V1|V2|V3
Run Code Online (Sandbox Code Playgroud)
笔记 :
应将上述文件内容作为输入并创建文件夹。
#ABC - MAIN PARENT DIRECTORY
#REMAINING AFTER ABC are child folders
Run Code Online (Sandbox Code Playgroud) uptime是否可以单独获取每个进程或用户的负载平均值(如所示)。
我希望能够看到哪些用户造成了哪些负载。
top不太合适,因为它只显示瞬时值。
有任何想法吗?
在 Ubuntu 20 上遇到一个奇怪的问题。我正在尝试获得硬件加速的 xrdp Xorg 会话。计算机视频为 Mesa DRI Intel(R) HD Graphics 4600 (HSW GT2)。我获取了 xrdp 的编译并安装的 devel 分支(Glamour 分支已合并)。
然后我尝试登录,但肉桂显示有关软件渲染的警告。我查看了 xorg 日志并发现了这一点:
[ 3987.463] (II) xfree86: Adding drm device (/dev/dri/card0)
[ 3987.463] (EE) systemd-logind: failed to take device /dev/dri/card0: Operation not permitted
Run Code Online (Sandbox Code Playgroud)
/dev/dri/card0 归 root 所有,具有视频组和组 rw acl。xrdp-sesman 使用以下命令从 uid 1000 的用户启动 Xorg 会话:
/usr/lib/xorg/Xorg :10 -auth .Xauthority -config xrdp/xorg.conf -noreset -nolisten tcp -logfile .xorgxrdp.%s.log
Run Code Online (Sandbox Code Playgroud)
我试过:
我有一个 38GB 的文件夹,里面有 800 个 MP4 视频。重新下载后,文件名没有空格,所有单词都连在一起,但还是TitleCase。
所以从TitleCase我需要Title Case。
批量重命名这些文件的最有效方法是什么?
我记得很久以前我的发行版中就包含了rename或autorename,但现在似乎没有了。
我有一个包含</w:rPr>多次标记的 xml 文件。它是这样使用的
<w:rPr><w:rFonts w:ascii="Symbol" w:hAnsi="Symbol" w:hint="default"/></w:rPr>
Run Code Online (Sandbox Code Playgroud)
然而,标签本身之间的内容有时是不同的。莫不是用sed的方式或其他东西删除之间的一切<w:rPr>和</w:rPr>,然后这两个标签呢?
相关的命名空间
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
Run Code Online (Sandbox Code Playgroud)
以及文件本身的一部分(格式化的、有效的 XML)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:numbering xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:cx="http://schemas.microsoft.com/office/drawing/2014/chartex" xmlns:cx1="http://schemas.microsoft.com/office/drawing/2015/9/8/chartex" xmlns:cx2="http://schemas.microsoft.com/office/drawing/2015/10/21/chartex" xmlns:cx3="http://schemas.microsoft.com/office/drawing/2016/5/9/chartex" xmlns:cx4="http://schemas.microsoft.com/office/drawing/2016/5/10/chartex" xmlns:cx5="http://schemas.microsoft.com/office/drawing/2016/5/11/chartex" xmlns:cx6="http://schemas.microsoft.com/office/drawing/2016/5/12/chartex" xmlns:cx7="http://schemas.microsoft.com/office/drawing/2016/5/13/chartex" xmlns:cx8="http://schemas.microsoft.com/office/drawing/2016/5/14/chartex" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:aink="http://schemas.microsoft.com/office/drawing/2016/ink" xmlns:am3d="http://schemas.microsoft.com/office/drawing/2017/model3d" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:w16cid="http://schemas.microsoft.com/office/word/2016/wordml/cid" xmlns:w16se="http://schemas.microsoft.com/office/word/2015/wordml/symex" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" mc:Ignorable="w14 w15 w16se w16cid wp14">
<w:abstractNum w:abstractNumId="0" w15:restartNumberingAfterBreak="0">
<w:nsid w:val="FFFFFF89"/>
<w:multiLevelType w:val="singleLevel"/>
<w:tmpl w:val="CB2CEC0E"/>
<w:lvl w:ilvl="0">
<w:start w:val="1"/>
<w:numFmt w:val="bullet"/>
<w:pStyle w:val="Aufzhlungszeichen"/>
<w:lvlText w:val="ï‚·"/>
<w:lvlJc w:val="left"/>
<w:pPr>
<w:tabs> …Run Code Online (Sandbox Code Playgroud)