所以我要做的就是写一个脚本来读取我的输入文件,然后做一些相应的事情。
我的输入文件以这种格式发送给我:
ID QTY
xxxxxxxxx,xxx
xxxxxxxxx,xx
xxxxxxxxx,xxx
xxxxxxxxx,xx
xxxxxxxxx,xx有时ID只有8位数,因为数字较小。如果发生这种情况,我需要将其格式化为前导零。另外,我的输入文件有数千行。
到目前为止,我有这个
echo "${processNew}"
## Read the file line-by-line and output the id.
IFS=','
while read line
do
echo "%09d\n" $line
done < ${processNew}发布于 2016-06-10 05:42:27
编辑:你就快完成了,只需要在你的代码中稍作调整,但不需要循环:)
如果想要打印这两列,请这样写
awk -F, '{printf "%09d,%d\n" ,$1,$2}' "${processNew}"如果只想打印ID列,请这样写
awk -F, '{printf "%09d\n" ,$1}' "${processNew}"https://stackoverflow.com/questions/37730487
复制相似问题