Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3958678
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T02:38:16+00:00 2026-05-20T02:38:16+00:00

Greetings. I have files that contains eleven fields in the file name. Each file

  • 0

Greetings.

I have files that contains eleven fields in the file name. Each file has a specific meaning. My job is to list each file name and load the info into a database table for reporting.

My awk code does this (files have VER suffix):

find . -name "*.VER" -exec ls '{}' ';' -printf %f\\t | awk -F"~" '{print $1"\t"$2"\t"$3"\t"$4"\t"$5"\t"$6"\t"$7"\t"$8"\t"$9"\t"$10"\t"$0}' > somefile.tab

It works fine except that it does something weird with the file name ($0): it repeats it like so (the 2 last fields from the right):

RRR1    PRE DTV_PREP    PREP05  JGM15453.   26  P   H23-600 029416589165    20110216    RRR1~PRE~DTV_PREP~PREP05~JGM15453.~26~P~H23-600~029416589165~20110216~090353.VER    ./RRR1~PRE~DTV_PREP~PREP05~JGMDTV269~33~P~H21-200~029384120357~20110216~091829.VER

If I remove “%f” switch from the printf statement, it seems to work but if I leave it alone and remove $0, file name never gets displayed. What am missing here? Any ideas?

Thanks for your input.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T02:38:16+00:00Added an answer on May 20, 2026 at 2:38 am

    awk isn’t printing it out twice, find is due to the ls and the -printf. I don’t see the reason for the -exec ls '{}' ';' anyway. You should be able to simply remove it like so:

    find . -name "*.VER" -printf "%f" | awk -F"~" '{print $1"\t"$2"\t"$3"\t"$4"\t"$5"\t"$6"\t"$7"\t"$8"\t"$9"\t"$10"\t"$11"\t"$0}'
    

    By the way, you can greatly simplify you code like so:

    find . -name "*.VER" -printf "%f" | awk -F'~' '{for(i=1;i<=NF;i++)printf("%s\t",$i)}1'
    

    Note that you were missing the 11th field $11 in your code. Both my answers will print this out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings, I have a bash script that parses ZIP files we receive from a
Greetings fellow amazonians We have certain f4v files from webtvinteractive.com that are not working
I have the following text file 40 timesteps took 58.320842 seconds greetings 0 80
Greetings I have a program that creates multiples instances of a class, runs the
Greetings! I have a Repeater control that's using an XmlDataSource control. <asp:FormView id=myFormView runat=server
Greetings, I have some mysql tables that are currently using an md5 hash as
Greetings, I have one file - more or less a greylisting file. I need
Greetings! So I have a base class that defines a base64Binary property to be
Greetings, I have file with the following strings: string.Format({0},{1}, Having \Two\ On The Same
Greetings, I have an application that allows users to import libraries (.NET DLLs) they've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.