首页 > 代码库 > head和tail命令

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

 

head和tail命令