Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12
Hi , I'm trying to extract file names using cut from zip file ...what i did.. #unzip -l gg.zip > hi #cat hi Archive: gg.zip Length Date Time Name -------- ...
  1. #1
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568

    Smile cut command -- problem

    Hi ,
    I'm trying to extract file names using cut from zip file ...what i did..

    #unzip -l gg.zip > hi

    #cat hi
    Archive: gg.zip
    Length Date Time Name
    -------- ---- ---- ----
    3447 11-23-06 17:01 gg/gg4_295_295.jpeg
    3447 11-23-06 17:01 gg/sunnystyle_295_295.jpeg
    3447 11-23-06 17:01 gg/aa_295_295 (copy).jpeg
    3447 11-23-06 17:01 gg/zz_295_295 (another copy).jpeg
    3447 11-23-06 17:01 gg/aa_295_295.jpeg
    3447 11-23-06 17:01 gg/zz_295_295.jpeg
    -------- -------
    20682 6 files

    # cut -f4 hi

    Archive: gg.zip
    Length Date Time Name
    -------- ---- ---- ----
    3447 11-23-06 17:01 gg/gg4_295_295.jpeg
    3447 11-23-06 17:01 gg/sunnystyle_295_295.jpeg
    3447 11-23-06 17:01 gg/aa_295_295 (copy).jpeg
    3447 11-23-06 17:01 gg/zz_295_295 (another copy).jpeg
    3447 11-23-06 17:01 gg/aa_295_295.jpeg
    3447 11-23-06 17:01 gg/zz_295_295.jpeg
    -------- -------
    20682 6 files
    --------------------------
    cut f4 displays whole contents instead of displaying filename only....how to display file only....
    thanks
    - Lakshmipathi.G
    -------------------
    FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
    First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -------------------

  2. #2
    Super Moderator devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,316
    there should be a space between -f and 4.
    Code:
    cut -f 4 hi
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

  3. #3
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568

    Smile

    no...i gave space between -f and 1 ...even then i'm getting same output....it displays whole file....do i have 2 use any delimiter option with cut ????
    - Lakshmipathi.G
    -------------------
    FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
    First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -------------------

  4. #4
    Super Moderator devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,316
    Code:
    cut -f4 -d' ' hi
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

  5. #5
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568

    Exclamation

    Hi,
    nope...even that's not working ....
    if i give cut -f4 -d' ' hi

    no output is disaplyed ...i attached that hi file..
    - Lakshmipathi.G
    -------------------
    FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
    First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -------------------

  6. #6
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568

    Post

    hi file is attached here...
    Attached Files Attached Files
    - Lakshmipathi.G
    -------------------
    FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
    First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -------------------

  7. #7
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568

    Post

    i think i found the root cause , the file(hi.txt) flieds are not sepated by TAB.....so -f is not working....how to fix this....
    3447 11-23-06 17:01 gg/gg4_295_295.jpeg

    there is 5 space before 3447 and
    2 blank space between 3447 and 11-23-06
    1 blank space between 11-23-06 and 17:01
    3 blank space between 17:01 and gg/gg4_295_295.jpeg
    - Lakshmipathi.G
    -------------------
    FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
    First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -------------------

  8. #8
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631
    You can solve this with awk:

    Code:
    awk '{print $4}' hi.txt
    Regards

  9. #9
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568
    ...awk works....thanks..
    - Lakshmipathi.G
    -------------------
    FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
    First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -------------------

  10. #10
    Linux Newbie
    Join Date
    Feb 2007
    Location
    hyderabad, india
    Posts
    247
    Quote Originally Posted by Franklin52 View Post
    You can solve this with awk:

    Code:
    awk '{print $4}' hi.txt
    Regards
    hi
    if this is the case how can i print
    Code:
    __bikes__
    a
    a@yahoo.com
    111111111111
    1234567890123456789044444
    1234567890123456789055555
    1234567890123456789022222
    __ONLINE__
    b
    b@gmail.com
    111111111111
    
    
    
    __cars__
    c
    c@yahoo.com
    111111111111
    1234567890123456789088888
    1234567890123456789088888
    1234567890123456789088888
    how can i print bikes first and cars second..
    means output is simply like this
    Code:
    name:a
    mail:a@yahoo.com
    h:1234567890123456789044444
    m:1234567890123456789055555
    o:1234567890123456789022222
    
    name:b
    mail:b@yahoo.com
    h:
    m:
    o:
    
    name:c
    -----------
    ----------
    -----------
    
    like this
    can you help me ..
    "Relationships are built on trust and communication"

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...