cut or awk command to print first field of first r

2020-05-13 12:18发布

I am trying print the first field of the first row of an output. Here is the case. I just need to print only SUSE from this output.

# cat /etc/*release

SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 2

Tried with cat /etc/*release | awk {'print $1}' but that print the first string of every row

SUSE
VERSION
PATCHLEVEL

8条回答
Luminary・发光体
2楼-- · 2020-05-13 12:53

You could use the head instead of cat:

head -n1 /etc/*release | awk '{print $1}'
查看更多
看我几分像从前
3楼-- · 2020-05-13 12:57

You can kill the process which is running the container.

With this command you can list the processes related with the docker container:

ps -aux | grep $(docker ps -a | grep container-name | awk '{print $1}')

Now you have the process ids to kill with kill or kill -9.

查看更多
登录 后发表回答