将Docker输出保存到主机
docker run centos cat /etc/hosts > asdf
"asdf“保存在我的主机Linux中。
将码头输出保存到容器中
docker run centos sh -c 'cat /etc/hosts > /tmp/asdf '
docker run centos cat /tmp/asdf
cat: /tmp/asdf: No such file or directory
它不工作,我怎么能猫新的文件?
在容器中使用"<“
docker run centos sh -c 'cat
这是我的样本文件
user@linux:~$ cat file.txt
Line 1
Line 2
Line 3
Line 4
Line 5
user@linux:~$
我可以用grep -A2 'e 2' file.txt打印第2-4行。
user@linux:~$ grep -A2 'e 2' file.txt
Line 2
Line 3
Line 4
user@linux:~$
我也可以用grep -n打印出行号。
user@linux:~$ grep -nA2 'e 2' file.txt
2:Line 2
3-Line 3
4
我有一个文件,其中第一行如下所示:
"Window Size" "Param 1" Result Time
所以它基本上有一些用空格隔开的单词。我需要一个Linux命令,它将在一个特定的位置读取这个单词,在这个位置上,括在量值标记中的单词应该被看作是一个单词(并且返回时没有标量标记)。
因此,如果我使用数字1执行命令(如果从0开始并不重要),则应该返回以下内容:
Window Size
如果与3一起执行,则应返回:
Result
知道该怎么做吗,也许是用awk?
我试图在bash中运行sed命令,但是它总是给我带来错误,我不知道我做错了什么。
这是代码:$sed 's/unix/linux/' geekfile.txt,这是错误消息:bash: s/unix/linux/: No such file or directory.
我尝试添加-i,它告诉我找不到命令。该怎么办呢。下面是我面临的问题的截图:
📷
将码头输出保存到宿主
中
docker run centos cat /etc/hosts > asdf
asdf保存在我的主机linux中。
将码头输出保存到容器
docker run centos sh -c 'cat /etc/hosts > /tmp/asdf '
docker run centos cat /tmp/asdf
cat: /tmp/asdf: No such file or directory
这不管用,我怎么做呢?
容器中的
<:
docker run centos sh -c 'cat < /etc/hosts'
我习惯于打字
$ cd
在bash中没有参数导航到我的主目录。
然而,由于一些未定的时间,这不再起作用,只是什么也不做。
设置了我的HOME变量:
$ echo $HOME
/home/me
这怎么可能呢?上面写着
If no directory operand is given and the HOME environment variable is set to a non-empty
value, the cd utility shall behave as if the directory named in the HOME environment
variable was speci
如何识别以特殊模式开头的行,并在行尾添加一些内容?
如果应该添加的模式尚未附加
假设我想在主机文件中找到一个特定的行,或者根据开头的模式,可能是一个ip地址,或者是行上方的注释。
例如:
#This is your hosts file
127.0.0.1 localhost linux
#This is added automatically
192.168.1.2 domain1. com
#this is added automatically to
192.168.1.2 sub.domain1.com www.domain1.com
当你找到我告诉你的IP时我该怎么
我正在尝试找出在docker容器中使用的Ubuntu的版本。
这个提到了cat /etc/lsb-release,它提供了:
cat: can't open '/etc/lsb-release': No such file or directory
uname -r给出了:
3.13.0-119-generic
FWIW,uname -a提供:
Linux <container id> 3.13.0-119-generic #166-Ubuntu SMP Wed May 3 12:18:55 UTC 2017 x86_64 Linux
你知道它是什么版本的U