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 6250993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:31:54+00:00 2026-05-24T13:31:54+00:00

I have created a script which splits filenames into components for database inserts: find

  • 0

I have created a script which splits filenames into components for database inserts:

find . -name "R*VER"  | while read fname
do
    awk -v squote="'" -v base=${fname##*/} '
        {
            split( base, a, "~" );          
            printf( "INSERT INTO REPORT (COL1,COL2,COL3,COL4,COL5,COL6,COL7,COL8)\n" );
            str = sprintf( "VALUES (\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\")", base, a[1], a[2], a[3], a[7], a[8], a[9], a[10] );
            gsub( "\"", squote, str );          # replace double quotes with singles
            print str;
        }'
done

It worked great until today. New file names have introduced where a[1] contains a space e.g something here~... .

Now, I have a mix of files that look like this:

R1~blah~blahblah...VER and
R 4~blah~blahblah...VER

I want to modify find from find . -name "R*VER" to find . -name "* *" but this will exclude all the files without spaces in the filename.

What is the most efficient way to do this?

  • 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-24T13:31:55+00:00Added an answer on May 24, 2026 at 1:31 pm

    Set the Internal Field Separtor variable, $IFS, to a newline, rather than a space. Example:

    #!/bin/sh
    filenames=`ls`
    IFS=$'\n'
    for fname in $filenames ; do
        echo "$fname: "
        awk '{print $0}' $fname
    done
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page which is largely created by DOM script, which generates a
I have created script to find selectivity of each columns for every tables. In
I have created a shell script to backup my webfiles + database dump, put
I have a controller called 'exposures' which I created automatically with the script/generate scaffold
I have created a python script which pulls data out of OLE streams in
i have created a gallery script, which first loads images to be shown http://bit.ly/9aQdr3
I have created a script which posts data to a page automatically. It can
I have created a custom PHP script which uploads information submitted by a form
I have created this php script which displays the contents of a designated directory
I have created a script in which a i have to create a image

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.