我有两个文件:
k.txt:
3 5 7 9 19 20
Run Code Online (Sandbox Code Playgroud)
h.txt:
000010
100001
111001
Run Code Online (Sandbox Code Playgroud)
如果我只使用 cat,则没有换行符。我需要一个命令来提供一个如下所示的文件:
3 5 7 9 19 20
000010
100001
111001
Run Code Online (Sandbox Code Playgroud) 我有 10 个字段,我想从第 5 个字段开始到第 10 个字段并忽略前 5 个字段。我如何在 awk 中使用 NF 来做到这一点?
f1 f2 f3 f4 f5 f6 f7 f8 f9 f10
c1 c2 c3 c4 c5 c6 c7 c8 c9 c10
Run Code Online (Sandbox Code Playgroud)
我只想显示:
f6 f7 f8 f9 f10
c6 c7 c8 c9 c10
Run Code Online (Sandbox Code Playgroud) 我想 cat 文件,但每行的最大长度有限制。例如,我有一个 10 行的文件,每行有 10000 个字符,我想打印每行的前 100 个字符。猫或其他替代品是否可以做到这样的事情?谢谢。
输入:文件包含数据:
ID Location Domaind
1 20 X
1 5 y
1 25 Z
2 1 L
2 150 N
2 50 M
3 50 J
4 33 k
4 3 I
Run Code Online (Sandbox Code Playgroud)
我必须根据 ID 和位置来安排这些数据。平均首先按位置升序排列 ID=1,然后从左到右打印域与位置相同的顺序。
输出如:
1 Y-X-Z
2 L-M-N
3 J
4 I-K
Run Code Online (Sandbox Code Playgroud) 我写了这个脚本但[:alnum:]不起作用。有人帮忙吗?
echo -n "Enter a password : "
read password
LEN=$(echo ${#password})
if [ $LEN -lt 10 ]; then
echo "$password is smaller than 10 characters"
else
if ! [ -z `echo $password | tr -d "[:alnum:]"` ]; then
echo "$password is a weak password"
else
echo "$password is a strong password"
fi
fi
echo
Run Code Online (Sandbox Code Playgroud) 有没有办法在 shell 窗口中列出文件内容,以便从右到左打印字符,而不是像往常一样从左到右打印?或者BIDI 算法根据当前文本引导线方向?
这在处理属于 RTL 语言(以及混合 LTR RTL 文档)的文本文件时是相关的,您希望在不加载到编辑器的情况下进行大量搜索和搜索...编辑器不喜欢大文件...
周围的东西cat可能很好:)
事实上,cat如果不存在任何已知信息,也许我会写一些东西,只是将每一行和管道颠倒过来。
我有一个大文件。我需要删除文件中第 3 列中数字小于 60 的所有行。
示例文件:
35110 Bacteria(100) Proteobacteria(59) Alphaproteobacteria(59)
12713 Bacteria(100) Bacteroidetes(100) Bacteroidia(100)
Run Code Online (Sandbox Code Playgroud)
期望的输出:
12713 Bacteria(100) Bacteroidetes(100) Bacteroidia(100)
Run Code Online (Sandbox Code Playgroud) 我希望输出前一行指定的两个位置 A 和 B 之间的字符。每对,两条线的长度相等,但对之间的长度可以不同。有没有一种有效的方法(巨大的文件大小)可以使用grep, sed, 或awk?
示例文件:
xxxxxxAxxxxxxBxxxxxx
1234567890MNOPQRSTUV
xxAxxxxxxxxxxxxxxBxxxxxx
1234567890MNOPQRSTUVWXYZ
Run Code Online (Sandbox Code Playgroud)
...
我想获得输出:
7890MNOP
34567890MNOPQRST
Run Code Online (Sandbox Code Playgroud)
...
我有一个看起来像这样的文本文件:
English words only
English and ???
?????
English words only
English and ???
?????
English words only
Also English words only
English and ???
?????
English words only
English and ???
?????
Run Code Online (Sandbox Code Playgroud)
请注意,在那里的中间有两行,English words only并且Also English words only,一前一后。
我需要做的是将这两行合并为由 a 分隔的一行/,如下所示:
English words only
English and ???
?????
English words only
English and ???
?????
English words only / Also English words only
English and ???
?????
English words only
English and ??? …Run Code Online (Sandbox Code Playgroud) 以 Fred Flintstone开头的行应附加一些字符串。?查找指定出现的 Fred Flintstone 并将其附加。
对于出现这种模式的任何人,我如何使用此命令?我试过
sed '/Fred Flintstone/ s/$/ someString/2' filename
Run Code Online (Sandbox Code Playgroud)
显然上面的一个不起作用。它适用于所有事件,但不适用于特定事件。(假设我想替换第一个或第二个或第三个 [其中任何一个])
示例文件 1:
Fred Flintstone
Johnson Stone
Fred Flintstone
Fred Flintstone
Michael Clark
Run Code Online (Sandbox Code Playgroud)
所需的输出文件 1:
Fred Flintstone
Johnson Stone
Fred Flintstone someString
Fred Flintstone
Michael Clark
Run Code Online (Sandbox Code Playgroud) command-line ×10
text-processing ×10
awk ×1
bash ×1
language ×1
libreoffice ×1
password ×1
regex ×1
rtl ×1
sed ×1