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

  • Home
  • SEARCH
  • 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 8635721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:02:54+00:00 2026-06-12T10:02:54+00:00

I have a script that i run on 2k servers simultaneously that creates a

  • 0

I have a script that i run on 2k servers simultaneously that creates a temp working directory on a NAS.

The script builds a list of files…the list could be 1k files or 1m files.
I run a for loop on the list to run some grep commands on each file

counter=0
num_files=`wc -l $filelist`
cat $filelist| while read line; do
do_stuff_here
counter=`expr $counter+ 1`
((percent=$counter/$num_files))
##CREATE a file named "$percent".percent
done

What I am thinking is I can take the total number of files from the list ( wc -l $filelist) and add a counter that i increase by 1 in the loop.
I can then divide $counter/$num_files.

This seems to work, but the problem I have is that I would like to rename the same file, instead of just creating a new one each time. What can i do here?

I do not want this to output to stdout/stderr….i already have enough stuff going to these places. I would like to be able to browse to a subdir in WinSCP and quickly see where each is.

  • 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-06-12T10:02:55+00:00Added an answer on June 12, 2026 at 10:02 am

    Try this one

    touch 0.percent 
    counter=0 
    num_files=$(wc -l $filelist)
    num_files=${num_files/ */}
    cat $filelist| while read line; do 
    do_stuff_here 
    mv -f {$((counter*100/num_files)),$((++counter*100/num_files))}.percent 
    done 
    rm -f *.percent
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a PowerShell script that will monitor a list of servers
I have this script that run to fix my menu bar to the browser
I have wrote a script that was run from a spreadsheet. I had One
I have a php script that is run once a minute. The script runs
I have a script that may be run manually or may be run by
I have a script that is taking too long to run and I have
I have a complex Powershell script that gets run as part of a SQL
So I have a script that, when run, plays an audio file which I
I have a file that is created by a script that is run during
I have a python script that I want always to run in the background.

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.