help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] have the same column L


From: Val Krem
Subject: Re: [Help-bash] have the same column L
Date: Tue, 18 Jul 2017 00:32:27 +0000 (UTC)

Hi all, Sorry for the confusion. I started using Linux environment recently. I  
found it very useful, and powerful. I am still learning.

The data that I am working on is ASCII file.  One of the column of the file  
contains alphanumeric and I want each row of this column to have the same 
columns length. 


Thank you for the help I  got right  what I wanted to do using this

cat filename |awk '{printf "%010s\n",$1}' | sed 's/ /0/g'








On Friday, July 14, 2017 2:36 PM, Greg Wooledge <address@hidden> wrote:



On Fri, Jul 14, 2017 at 03:20:58PM -0400, Chris F.A. Johnson wrote:

> On Fri, 14 Jul 2017, Val Krem wrote:
> > A135953
> > D10036050
> > C135858000
> > 
> > I want add leading zeros and the column length should be 10
> > 
> > I tried
> > awk '{ printf "%010s \n", $1}' filename
> 
>   awk '{ printf "%010d \n", $1}' filename

Yeah, except his input isn't numeric.  We don't know what it is, because
he won't TELL US.

$ echo "A135953" | awk '{ printf "%010d \n", $1}'
0000000000 

Asking to zero-pad these non-numeric strings is completely nonsensical,
so I'm just waiting for a real explanation.  I don't expect one to
come out.  This person has a long history of asking ridiculous things
out of the blue.  It all smells like homework.

Some other people on the list have guessed that perhaps the input
strings are hexadecimal, and have given printf commands that would
be appropriate for that case.


reply via email to

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