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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:47:24+00:00 2026-06-16T08:47:24+00:00

I have a bunch of files and a script which I run on them.

  • 0

I have a bunch of files and a script which I run on them. That script takes 2 files as an input and all files are in this format: a.txt1 a.txt2

Now the script I use is like this: foo.sh a.txt1 a.txt2

I have to run this script run on 250 pairs (eg. a1.txt1 a1.txt2 to a250.txt1 a250.txt2)
I am doing this manually by entering file names. I was wondering is there any way to automate this process. All these pairs are in same folder, is there any way to loop the process on all pairs?

I hope I made it clear.

Thank you.

To be specific, these are some sample file names:

  • T39_C.txt2
  • T39_D.txt1
  • T39_D.txt2
  • T40_A.txt1
  • T40_A.txt2
  • T40_B.txt1
  • T40_B.txt2
  • T40_C.txt1
  • T40_C.txt2
  • T40_D.txt1
  • T40_D.txt2
  • unmatched.txt1
  • unmatched.txt2
  • WT11_A.txt1
  • WT11_A.txt2
  • WT11_B.txt1
  • WT11_B.txt2
  • WT11_C.txt1
  • 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-16T08:47:25+00:00Added an answer on June 16, 2026 at 8:47 am

    Assuming all files are in pairs (ie, <something>.txt1 and <something>.txt2 then you can do something line this:

    1. #!/bin/bash
    2.
    3. for txt1 in *.txt1; do
    4.    txt2="${txt1%1}2"
    5.    # work on $txt1 and $txt2
    6. done
    

    In line 3, we use a shell glob to grab all files ending with .txt1. Line 4, we use a substitution to remove the final 1 and replace it with a 2. And the real work is done in line 5.

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

Sidebar

Related Questions

I have a bunch of files that were named in a somewhat standard format.
I have a folder full of script files. When I run them, a program
Okey this is really strange. I have this script which basically downloads bunch of
I have a bunch of html files that come with my app and are
I have a bunch of .doc files in a folder which I need to
I have a bunch of log files which are pure text. Here is an
I have a bunch of XML files that are about 1-2 megabytes in size.
I have a bunch of MP4-Files and need to add comments to them. They
I have a project with a bunch of .png files that I want to
I have a bunch of urls in static html files which need to be

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.