小编use*_*748的帖子

从shell中的每一行提取最后一个单词

我有文件result.txt,看起来像这样:

acb.xyz.asd
mnt.x.sdr
s.ere.43
Run Code Online (Sandbox Code Playgroud)

我想编写将提取最后一个单词并打印如下的shell脚本:

asd
sdr
43
Run Code Online (Sandbox Code Playgroud)

我尝试了awk命令,但没有成功:

awk 'NF>1{print $NF}' result.txt
Run Code Online (Sandbox Code Playgroud)

我认为我需要使用定界符“。” 然后根据解析结果解析result.txt。请帮助。

bash shell

3
推荐指数
1
解决办法
3742
查看次数

通过管道将参数传递给日期命令

通过date -d从文件中读取将日期和时间传递给命令

我试过:

#cat temp.txt
2013/10/31 10:57:02
#cat temp.txt | xargs date -d
date: the argument `10:57:02' lacks a leading `+';
when using an option to specify date(s), any non-option
argument must be a format string beginning with `+'
Run Code Online (Sandbox Code Playgroud)

unix shell

1
推荐指数
1
解决办法
2771
查看次数

标签 统计

shell ×2

bash ×1

unix ×1