我对这个cut命令没有异议。
wolf@linux:~$ echo ab cd ef
ab cd ef
wolf@linux:~$ echo ab cd ef | cut -d ' ' -f 1
ab
wolf@linux:~$ echo ab cd ef | cut -d ' ' -f 2
cd
但是,当我尝试使用这样的不同输入的相同命令时,我没有得到预期的输出。
wolf@linux:~$ ip address show eth0 | grep 'inet '
inet 10.10.10.10/24 brd 10.10.10.25
我有一个ascii文件,内容如下:
START
this is my home
this is my pc
START
this is my linux
this is my awk
this is nice
START
this is a single line
START
this is my work
this is the end
this line has to be read
START
...
...
START
.
.
.
.
我希望读取开始行和空行之间的行,并以分隔格式打印输出。产出应采用以下格式:
this is my home;this is my pc
thi
我有疑问。如果我在libre (linux )中打开tsv文件,那么每一列中的每个选项卡分隔字符串。但是如果我使用awk,我只收到由空格分隔的字符串的第一部分。
F.E.:Libre办公室:
a how much I need 0 b
b 0 0 a
c 0 15 c
d It is really wierd 0 d
如果我用:
awk -v OFS="\t" '{print $2}' tsv_file
how
0
0
It
但我想要收到
how much I need
0
0
It i
输入:
START
OS:: UNIX
Release: xxx
Version: xxx
END
Description about UNIX
<Multiline>
START
OS:: LINUX
Release: xxx
Version: xxx
END
Description about LINUX
<Multiline>
START
OS:: Windows
Release: xxx
Version: xxx
END
Description about Windows
<Multiline>
在这里,我试图获得所有的信息之间的开始和结
我正在了解如何从类似于以下内容的输出中提取IP信息:
Fri Jun 9 19:01:54 2017,10.0.0.65,devi1,0,unknown os
Fri Jun 9 19:01:54 2017,10.0.0.55,host1,0,unknown os
Fri Jun 9 19:01:54 2017,10.0.0.35,srv01,0,unknown os
Sat Jun 10 23:11:13 2017,10.0.0.10,switch.domain.com,0,unknown os
任何关于如何从输出中获得以下信息的提示:
10.0.0.65
10.0.0.55
10.0
有以下字符串。
[root@fedoravm001 ~]# mysql -V
mysql Ver 14.14 Distrib 5.5.38, for Linux (x86_64) using readline 5.1
根据上面的内容,我可以解析并获得所需的版本号如下:
[root@fedoravm001 ~]# mysql -V | awk '{print $5 }'
5.5.38,
我不想要字符串5.5.38末尾的逗号
答案是: mysql -V \\ awk '{print $5}‘AC.26 awk 'gsub(",$","
开场白:我们的任务是尽快实现一个brainfuck解释器。为了让这个解释器尽可能快,我们想让一些聪明的指令,比如-<+>,对我们的解释器来说是原生的。我们想要用更多的指令来做这件事,所以我们想知道我们应该实现哪些指令。
我们发现了很多关于比较两个独立文件的信息,但是有没有办法在一个文件中找到重复出现的字符串呢?例如:
文件:
Hi, this is my text
also, it is an example of my question
返回:
2 x ' is '
2 x ' my '
2 x ', '
你知道在Windows或L
我试图使用shell脚本将文件中的句子分割成不同的行。
现在我想把绳子分开!?或者。。输出应该如下:
我想从my_text.txt读取并包含的文件。
you want to learn shell script? First, you want to learn Linux command! then. you can learn shell script.
现在我想用“!”来分弦。或者"?“或者“。”输出应该如下:
您想先学习shell脚本,然后学习Linux命令,然后再学习shell脚本。
我用了这个脚本:
while read p
do
echo $p | tr "
有没有一种方法可以在上面的行后面加上"java版本或许可被拒绝“这一行,在它们之间加一个?我希望在用于red hat 6的bash上实现数据操作目的。
谢谢
/apps/orautil/app/oracle/product/12.1.0/client_1/jdk/jre/lib/
java version "1.6.0_75"
/export/file/node/jre1.8.0_171/lib/
java version "1.8.0_171"
/test/jre1.8.0_171_linux/lib/
java version "1.8.
Unix 'file‘命令有一个-0选项,用于在文件名后输出空字符。这应该是和'cut‘一起使用的好方法。
来自man file
-0, --print0
Output a null character ‘\0’ after the end of the filename. Nice
to cut(1) the output. This does not affect the separator which is
still printed.
(注意,在我的Linux上,没有打印'-F‘分隔符--这对我来说更有意义。