shell文本左右对齐排版【转】


文本左右对齐排版

有文本4.txt如下:

111111111111111111111 98912 张三 
222222222222222222 150020 李四四 
333333333333333333333 360000 王五 
444444444444444444 2332 赵六六 
555555555555555555 222 田七 
666666666666666666666 999999

简单的文本通过批处理排版

这里写图片描述

编写代码


#! /bin/bash file=./4.txt echo -e "\n左对齐\n" while read line do printf "%-30s %-10d %-10s\n" ${line} done < ${file} echo -e "\n右对齐\n" while read line do printf "%30s %10d %10s\n" ${line} done < ${file}

 

运行结果

这里写图片描述

 

转自

文本左右对齐排版--shell - CSDN博客
https://blog.csdn.net/dengjili/article/details/77800546


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM