string operation - awk

This is a discussion on string operation - awk ; I have one file like: 1 234 2 34 4 345 3 1 How can I change the file into the following file: 1 0234 2 0034 3 0345 4 0001 Thank you...

+ Reply to Thread
Results 1 to 4 of 4

string operation

  1. Default string operation

    I have one file like:

    1 234
    2 34
    4 345
    3 1

    How can I change the file into the following file:

    1 0234
    2 0034
    3 0345
    4 0001

    Thank you


  2. Default Re: string operation

    On 25 Jul., 16:51, qingpin <chunkaow...> wrote:
    > I have one file like:
    >
    > 1 234
    > 2 34
    > 4 345
    > 3 1
    >
    > How can I change the file into the following file:
    >
    > 1 0234
    > 2 0034
    > 3 0345
    > 4 0001
    >
    > Thank you


    awk '{printf ("%d %04d\n", $1, $2)}'


    Janis


  3. Default Re: string operation

    qingpin <chunkaowang> writes:

    > I have one file like:
    >
    > 1 234
    > 2 34
    > 4 345
    > 3 1
    >
    > How can I change the file into the following file:
    >
    > 1 0234
    > 2 0034
    > 3 0345
    > 4 0001


    awk '{printf("%d %04d\n",$1,$2)}'

    is *probably* what you want, if the rest of your input is similar.

    Cheers,

    - Joel

  4. Default Re: string operation

    On Jul 25, 5:16 pm, Joel Reicher <j...@panacea.null.org> wrote:
    > qingpin <chunkaow...> writes:
    > > I have one file like:

    >
    > > 1 234
    > > 2 34
    > > 4 345
    > > 3 1

    >
    > > How can I change the file into the following file:

    >
    > > 1 0234
    > > 2 0034
    > > 3 0345
    > > 4 0001

    >
    > awk '{printf("%d %04d\n",$1,$2)}'
    >
    > is *probably* what you want, if the rest of your input is similar.
    >
    > Cheers,
    >
    > - Joel


    Thank you very much!


+ Reply to Thread

Similar Threads

  1. Re: Urgent help - String operation
    By Application Development in forum labview
    Replies: 0
    Last Post: 12-08-2007, 03:10 PM
  2. Re: Urgent help - String operation
    By Application Development in forum labview
    Replies: 1
    Last Post: 12-08-2007, 02:40 PM
  3. I/O operation, file operation behaviou
    By Application Development in forum c++
    Replies: 2
    Last Post: 08-16-2007, 02:13 PM
  4. Replies: 2
    Last Post: 06-26-2007, 02:19 PM
  5. Reading a text file into a string in one operation
    By Application Development in forum Java
    Replies: 4
    Last Post: 05-17-2004, 07:28 AM