Chủ Nhật, 3 tháng 2, 2013

Xử lý khoảng cách trong file


File đầu vào:
111       11111
      22222222
333 3 3333
4 4 4 4 4 44444

55555            5

File out:
111 11111
22222222
333 3 3333
4 4 4 4 4 4 4
55555 5


      code:  
cat test | sed -e 's/  */ /g' -e 's/^ *//g' -e 's/ *$//g' -e '/^ *$/d' >out
while read line
do
echo "   $line"
done <out

Không có nhận xét nào:

Đăng nhận xét