需求描述:linux
今天在對一個從excel文件中粘出來的內容進行整理的時候,發現格式很亂,就想用awk工具格式化一下,在此記錄一下.electron
操做過程:工具
1.從excel中複製出來的內容spa
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
備註:就想要第一列是對齊的,同時第二列也是對齊的.excel
2.使用awk進行格式化(首先將上面的內容粘貼到linux一個文件中)code
[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表示輸出字符串,而且經過負號(-),數字表示的是左對齊輸出.這樣就達到了對格式進行整理.orm
文檔建立時間:2018年7月12日10:59:29blog