bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: have the same column L


From: Peter & Kelly Passchier
Subject: Re: have the same column L
Date: Fri, 14 Jul 2017 11:08:45 +0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

Assuming the input is hexadecimal, a function like this would format each line as intended:

  formatline() { printf "%010X \n";}

Then a line like this would give the intended result:

  while read -r; do fl $REPLY; done <filename

Of course, many assumptions and no error checking here...

Cheers,
Peter


On 07/14/2017 08:29 AM, Krem wrote:
Hi all,

How can I starndarzied string column to have the same column length for each 
row.

Example
filename

A135953
D10036050
C135858000

I want add leading zeros and the column length should be 10

I tried
awk '{ printf "%010s \n", $1}' filename

Got all zeros
0000000000
0000000000
0000000000
0000000000

But I want
000A135953
0D10036050
C135858000


I would appreciate if you help me out.

thank you in advance




--
View this message in context: 
http://gnu-bash.2382.n7.nabble.com/have-the-same-column-L-tp19574.html
Sent from the Gnu - Bash mailing list archive at Nabble.com.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]