-3

2 つの unl ファイルがあります。sample.unl test.unl 以下の cat コマンドを使用すると、出力が適切にフォーマットされません。

{
cat sample.unl
echo
cat test.unl
}

.

store_nbr   country_code    date    
400  CA 2010-06-11 12:00:49

以下のように出力を適切に配置したい..

store_nbr             country_code               date   
400                   CA                         2010-06-11 12:00:49

私を助けてください..ありがとう

4

1 に答える 1

1

そのための小さな python スクリプトを記述します。

$ cat format.py 
#!/usr/bin/python

import sys, re

with open(sys.argv[1], "r") as f:
    for line in f:
        print "%-20s %-20s %-20s" % tuple(re.split('\s+', line.rstrip('\n'), 2))

使用例:

$ python format.py sample.unl
store_nbr            country_code         date                
400                  CA                   2010-06-11 12:00:49 
于 2012-07-11T18:18:07.173 に答える