如何在一个 bash 命令中执行以下操作?我的意思是将文件重命名为当前日期
$ echo `date +"%m-%d-%y"`
01-14-16
$ mv backup1.tar 01-14-16
Run Code Online (Sandbox Code Playgroud) 嘿,我需要在“文件”中的第 2 行和第 3 行之间交换三个连续行:
$cat file
Object Name: A
comments: comment A
manual_encdomain: Name: A
Object Name: B
comments: comment B
manual_encdomain: Name: B
Run Code Online (Sandbox Code Playgroud)
所以而不是下面的输出:
$sed 'N;N;s/\n/ /g' file
Object Name: A comments: comment A manual_encdomain: Name: A
Object Name: B comments: comment B manual_encdomain: Name: B
Run Code Online (Sandbox Code Playgroud)
我宁愿需要这个
Object Name: A manual_encdomain: Name: A comments: comment A
Object Name: B manual_encdomain: Name: B comments: comment B
Run Code Online (Sandbox Code Playgroud)
sed, awk 任何东西
我有基于 ARM cpu 的 BusyBox v1.8.1(嵌入式 Linux),二进制文件有限。如何在不使用 curl 的情况下 http 发布或放置?我有可用的 wget:
# wget
BusyBox v1.8.1 (2015-04-06 16:22:12 IDT) multi-call binary
Usage: wget [-c|--continue] [-s|--spider] [-q|--quiet] [-O|--output-document file]
[--header 'header: value'] [-Y|--proxy on/off] [-P DIR]
[-U|--user-agent agent] url
Retrieve files via HTTP or FTP
Options:
-s Spider mode - only check file existence
-c Continue retrieval of aborted transfer
-q Quiet
-P Set directory prefix to DIR
-O Save to filename ('-' for stdout)
-U Adjust 'User-Agent' field
-Y Use …
Run Code Online (Sandbox Code Playgroud) 我有文件 test1 与这样的行:
A B C
D E F
...
Run Code Online (Sandbox Code Playgroud)
我想让文件 test2 带有以下行:
DDD EEE FFF A
DDD EEE FFF D
...
Run Code Online (Sandbox Code Playgroud)
其中 A 和 D 在短语 DDD EEE FFF 之后从 test1 文件的第一列复制到 test2 文件
我开始如下,
cat test1 | echo "DDD EEE FFF " `awk '{print $1}'` > test2
Run Code Online (Sandbox Code Playgroud)
但当然它只添加短语 DDD EEE FFF 一次,然后附加 A、D,这不是我想要的
DDD EEE FFF A D
Run Code Online (Sandbox Code Playgroud)