linux中通过awk进行文本的对齐格式化处理?awk printf左对齐?
需求描述:
今天在对一个从excel文件中粘出来的内容进行整理的时候,发现格式很乱,就想用awk工具格式化一下,在此记录一下.
操作过程:
1.从excel中复制出来的内容
job_name job_group
syncCommStockJob dataSync
syncStoreChnlJob dataSync
syncOrderJob dataSync
syncReportStoreJob dataSync
hdfsScanJob report
orderSaleDailyJob report
jdzmdOrdersJob report
jdCanJob report
tbTermSalesJob report
ess3GTermSalesJob report
npBusiDayReportJob report
npBusiWeekMonthReportJob report
snOrdersScreenJob report
jdzmdOrderScreenJob report
jjTermSalesJob report
termSalesJob report
jfScanJob report
operatorSalesJob report
operatorSpecialSalesJob report
syncTopSaleByDayJob report
operatorDataJob report
npBusiSpecWeekMonthReportJob report
analyseTopSaleDayJob report
analyseTopSaleWeekAndMonthJob report
clearScreenCacheJob report
commStockReportJob report
costDetailJob report
incomeDetailJob report
bigScreenIncomeAndCostJob report
termSaleGatherDayJob report
termSalesGatherJob report
mobileSaleGatherDayJob report
mobileTermSalesGatherJob report
incomeAndCostReportJob report
businessInfoMonitorJob report
ticketBigDataJob report
activityStatisticsByDayJob report
detectFtpFileJob report
electronicKafkaInfoJob report
storePerformmanceJob report
bdElectronicKafkaDataJob report
testJob service
reportJob service
topSessionJob service
topGetStoresJob service
topItemsGetJob service
topGoodsDetailJob service
topTradeDownloadJob service
topUserPermitJob service
topMsgConsumerJob service
bdStoreChlJob service
bdSmsPushJob service
smsFeedbackJob service
targetUserJob service
propertyInfoJob service
storeAndAdminAreaUploadJob service
newTargetUserJob service
blackAndWhiteListSynJob service
areaCacheJob sysman
departCacheJob sysman
departJianPinJob sysman
allAreaCacheJob sysman
staffCacheJob sysman
areaSyncJob sysman
allFuncrightCacheJob sysman
synDepartJob sysman
originDepartCacheJob sysman
allAdminAreaCacheJob sysman
adminAreaCacheJob sysman
testAJob sysman
testBJob sysman
storeCacheJob sysman
备注:就想要第一列是对齐的,同时第二列也是对齐的.
2.使用awk进行格式化(首先将上面的内容粘贴到linux一个文件中)
[root@testvm ~]# cat abc.txt | awk '{printf "%-30s%-15s\n",$1,$2}' #%-30s表示输出字符串,宽度30位,左对齐.%-15s用来指定第二列的,左对齐,宽度15.两个百分号之间可以没有空格.使用\n对每一行的输出加上换行符
job_name job_group
syncCommStockJob dataSync
syncStoreChnlJob dataSync
syncOrderJob dataSync
syncReportStoreJob dataSync
hdfsScanJob report
orderSaleDailyJob report
jdzmdOrdersJob report
jdCanJob report
tbTermSalesJob report
ess3GTermSalesJob report
npBusiDayReportJob report
npBusiWeekMonthReportJob report
snOrdersScreenJob report
jdzmdOrderScreenJob report
jjTermSalesJob report
termSalesJob report
jfScanJob report
operatorSalesJob report
operatorSpecialSalesJob report
syncTopSaleByDayJob report
operatorDataJob report
npBusiSpecWeekMonthReportJob report
analyseTopSaleDayJob report
analyseTopSaleWeekAndMonthJob report
clearScreenCacheJob report
commStockReportJob report
costDetailJob report
incomeDetailJob report
bigScreenIncomeAndCostJob report
termSaleGatherDayJob report
termSalesGatherJob report
mobileSaleGatherDayJob report
mobileTermSalesGatherJob report
incomeAndCostReportJob report
businessInfoMonitorJob report
ticketBigDataJob report
activityStatisticsByDayJob report
detectFtpFileJob report
electronicKafkaInfoJob report
storePerformmanceJob report
bdElectronicKafkaDataJob report
testJob service
reportJob service
topSessionJob service
topGetStoresJob service
topItemsGetJob service
topGoodsDetailJob service
topTradeDownloadJob service
topUserPermitJob service
topMsgConsumerJob service
bdStoreChlJob service
bdSmsPushJob service
smsFeedbackJob service
targetUserJob service
propertyInfoJob service
storeAndAdminAreaUploadJob service
newTargetUserJob service
blackAndWhiteListSynJob service
areaCacheJob sysman
departCacheJob sysman
departJianPinJob sysman
allAreaCacheJob sysman
staffCacheJob sysman
areaSyncJob sysman
allFuncrightCacheJob sysman
synDepartJob sysman
originDepartCacheJob sysman
allAdminAreaCacheJob sysman
adminAreaCacheJob sysman
testAJob sysman
testBJob sysman
storeCacheJob sysman
备注:使用printf进行输出第一列和第二列.然后使用%s表示输出字符串,并且通过负号(-),数字表示的是左对齐输出.这样就达到了对格式进行整理.
文档创建时间:2018年7月12日10:59:29
linux中通过awk进行文本的对齐格式化处理?awk printf左对齐?的更多相关文章
- wordpress 后台富文本编辑器,添加图片发现无法左对齐,样式出现混乱
如上图所示,无法左对齐,但是左对齐的按钮全部是正确的,最后一点点排除,发现是因为这个词的影响,去掉就好了,原因不明,可能是这个词被当做某个方法执行了
- bootstrap 轮播图带缩列图两端对齐,并自动换行然后左对齐!
禁止自动轮播 data-interval="false" 完整代码如下: 1 <!DOCTYPE html> 2 <html> 3 4 <head&g ...
- Linux中图形界面和文本模式相互切换
1.默认开机进入文本模式 如果想让开机自动进纯文本模式, 修改/etc/inittab 找到其中的 id:5:initdefault: 这行指示启动时的运行级是5,也就是图形模式 改成3就是文本模式了 ...
- css 单行文本居中显示,多行文本左对齐
父级元素 text-align:center; 自级元素 text-align:left; display:inline-block;
- linux中awk命令(最全面秒懂)
目录 一:linux中awk命令 1.awk命令简介 2.awk作用 3.awk的语法格式 4.解析awk使用方法 5.参数 6.awk的生命周期 二:awk中的预定义变量 三:awk运行处理规则的执 ...
- linux中awk命令详解(最全面秒懂)
一:linux中awk命令 1.awk命令简介 AWK 是一种处理文本文件的语言,是一个强大的文本分析工具. 之所以叫 AWK 是因为其取了三位创始人 Alfred Aho,Peter Weinber ...
- linux(六)之文本操作
接下来我们一起来看一下再linux中怎么去对文本进行操作的 一.文本文件 既然要操作文本,所以我们要对文本有一个了解,那什么是文本文件呢. 文本文件是一种由若干行字符构成的计算机文件.文本文件存在于计 ...
- linux中vi编辑器的使用
vi编辑器是所有Unix及Linux系统下标准的编辑器,它的强大不逊色于任何最新的文本 编辑器,这里只是简单地介绍一下它的用法和一小部分指令.由于对Unix及Linux系统的任 何版本,vi编辑器是完 ...
- iOS上让按钮文本左对齐问题
一,问题分析 1.在做历史记录视图的时候,由于让键盘退出后才能触发表格的 didselect 那个代理方法,也就是得点两下才触发,而表格中的按钮点一下就可以立即响应. 2.于是我就有了用按钮事件代替 ...
随机推荐
- Virtools元素、类和面向对象设计
无意中发现了在某个不存在的网站( https://sites.google.com )上,还存有09年写的一些半成品教材,下面这篇文章就是其中一部分. 概述 Virtools将元素(Element)组 ...
- netty tcp拆包
private List<byte[]> getCompletePacket(byte[] bytes, ByteBuf byteBuf) { byte[] clone = bytes.c ...
- Parse how to write flash in uefi shell.
Step: 1. Enable 2. Read 3. Write 4. Disable FI_GUID gEfiSFlashProtocolGuid = FLASH_P ...
- SpringMVC登录拦截器
springmvc拦截器的配置.使用:1.自定义拦截器,实现HandlerInterceptor接口. package com.bybo.aca.web.interceptor; import jav ...
- Android安装后没有完成和打开按钮
File apkFile = new File(filePath); Intent intent = new Intent(); intent.setFlags(Intent.FLAG_ACTIVIT ...
- css样式冲突问题练习例子
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org ...
- 【转】Memcached之缓存雪崩,缓存穿透,缓存预热,缓存算法
缓存雪崩 缓存雪崩可能是因为数据未加载到缓存中,或者缓存同一时间大面积的失效,从而导致所有请求都去查数据库,导致数据库CPU和内存负载过高,甚至宕机. 解决思路: 1,采用加锁计数,或者使用合理的队列 ...
- Qt之QLocalServer
简述 QLocalServer提供了一个基于本地socket的server. QLocalServer可以接受来自本地socket的连接.通过调用listen(),让server监听来自特定key的连 ...
- Some Parameter Interpretation On Using Mininet
MiniNet使用很简单,下面以下面帮助界面截图为例,简单讲述常见的几个命令即可: sudo mn --topo single,3--mac --switch ovsk--controller rem ...
- 【Android】解决Android横竖屏切换数据丢失问题的方法
解决方案1:在Androidmanifest.xml的activity标签中加入android:screenOrientation="portrait",可以屏蔽横屏 <ac ...