Linux seq命令的使用詳解
01. 命令概述
seq命令用于產(chǎn)生整數(shù)序列。
02. 命令格式
用法:
seq [選項(xiàng)]... 尾數(shù) seq [選項(xiàng)]... 首數(shù) 尾數(shù) seq [選項(xiàng)]... 首數(shù) 增量 尾數(shù)
03. 常用選項(xiàng)
以指定增量從首數(shù)開始打印數(shù)字到尾數(shù)。
-f, --format=格式 使用printf 樣式的浮點(diǎn)格式 -s, --separator=字符串 使用指定字符串分隔數(shù)字(默認(rèn)使用:\n) -w, --equal-width 在列前添加0 使得寬度相同 --help 顯示此幫助信息并退出 --version 顯示版本信息并退出
04. 參考示例
4.1 輸出1-5
[deng@localhost ~]$ seq 5 1 2 3 4 5 [deng@localhost ~]$
4.2 輸出1-5
[deng@localhost ~]$ seq 1 5 1 2 3 4 5 [deng@localhost ~]$
4.3 輸出3-5
[deng@localhost ~]$ seq 3 5 3 4 5 [deng@localhost ~]$
4.4 輸出1 4 7 10
[deng@localhost ~]$ seq 1 3 10 1 4 7 10 [deng@localhost ~]$
4.5 指定格式輸出
[deng@localhost ~]$ seq -f "%3g" 9 11 9 10 11 [deng@localhost ~]$
意思是-f指定格式,%后面指定3位數(shù),默認(rèn)是%g,%3g不夠位數(shù)的地方都是空格填補(bǔ)
4.6 指定格式輸出
[deng@localhost ~]$ seq -f "%03g" 9 11 009 010 011 [deng@localhost ~]$
意思是打印三位,不足的地方用0填補(bǔ)
4.7 指定格式輸出
[deng@localhost ~]$ seq -f "str%03g" 9 11 str009 str010 str011 [deng@localhost ~]$
意思是打印三位不足的地方以0填補(bǔ),在前面加上str
4.8 在列前添加0使得寬度相同
[deng@localhost ~]$ seq -w 9 11 09 10 11 [deng@localhost ~]$
當(dāng)輸出等寬字符串時(shí)不應(yīng)再指定格式字符串,-w與-f不能一起用
4.9 使用指定字符串分隔數(shù)字
[deng@localhost ~]$ seq -s " " -f "str%03g" 9 11 str009 str010 str011 [deng@localhost ~]$
4.10 使用tab鍵分隔數(shù)字
[deng@localhost ~]$ seq -s "`echo -e '\t'`" 9 11 9 10 11 [deng@localhost ~]$
先用命令做成一個(gè)tab,然后再指定成分隔符
05. 附錄
參考: 【Linux】一步一步學(xué)Linux系列教程匯總
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持本站。
版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。