波神

导航

head和tail命令

vim Dockerfile

############################################################
#dckerfile to build mysql for mir container images
# Based on Ubuntu
# ############################################################
FROM 172.16.101.192/common/mysql:5.6
# File Author / Maintainer
MAINTAINER huzhengbo
#ADD mir_scalr.sql to container docker-entrypoint-initdb.d
ADD analytics.sql /docker-entrypoint-initdb.d
ADD scalr.sql /docker-entrypoint-initdb.d
ADD keycloak.sql /docker-entrypoint-initdb.d
ADD mirmon.sql /docker-entrypoint-initdb.d
ADD mir_scalr.sql /docker-entrypoint-initdb.d
ADD mir_pack.sql /docker-entrypoint-initdb.d
ADD oneaa.sql /docker-entrypoint-initdb.d
ADD one_log.sql /docker-entrypoint-initdb.d
#the mysql port
EXPOSE 3306

head得到头部6行

head -n +6 Dockerfile或head -n 6 Dockerfile

[root@localhost mysqlDockerfile]# head -n +6 Dockerfile 
############################################################
#dckerfile to build mysql for mir container images
# Based on Ubuntu
# ############################################################
FROM 172.16.101.192/common/mysql:5.6
# File Author / Maintainer

删掉尾部2行(并没有从文件删除掉)

head -n -6 Dockerfile

############################################################
#dckerfile to build mysql for mir container images
# Based on Ubuntu
# ############################################################
FROM 172.16.101.192/common/mysql:5.6
# File Author / Maintainer
MAINTAINER huzhengbo
#ADD mir_scalr.sql to container docker-entrypoint-initdb.d
ADD analytics.sql /docker-entrypoint-initdb.d
ADD scalr.sql /docker-entrypoint-initdb.d
ADD keycloak.sql /docker-entrypoint-initdb.d
ADD mirmon.sql /docker-entrypoint-initdb.d

删除掉头部6行

tail -n +5 Dockerfile或tail -n 5 Dockerfile

FROM 172.16.101.192/common/mysql:5.6
# File Author / Maintainer
MAINTAINER huzhengbo
#ADD mir_scalr.sql to container docker-entrypoint-initdb.d
ADD analytics.sql /docker-entrypoint-initdb.d
ADD scalr.sql /docker-entrypoint-initdb.d
ADD keycloak.sql /docker-entrypoint-initdb.d
ADD mirmon.sql /docker-entrypoint-initdb.d
ADD mir_scalr.sql /docker-entrypoint-initdb.d
ADD mir_pack.sql /docker-entrypoint-initdb.d
ADD oneaa.sql /docker-entrypoint-initdb.d
ADD one_log.sql /docker-entrypoint-initdb.d
#the mysql port
EXPOSE 3306

得到尾部5行

tail -n -5 Dockerfile

ADD mir_pack.sql /docker-entrypoint-initdb.d
ADD oneaa.sql /docker-entrypoint-initdb.d
ADD one_log.sql /docker-entrypoint-initdb.d
#the mysql port
EXPOSE 3306

 

posted on 2017-02-16 12:43  波神  阅读(320)  评论(0编辑  收藏  举报