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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:35:04+00:00 2026-06-11T02:35:04+00:00

I need a shell script that basically does this: Searches in a folder for

  • 0

I need a shell script that basically does this:

  • Searches in a folder for all the txt files, and for each one it finds, creates a individual zip file with the same of the txt file it found + .zip.
  • After that moves the created zip file to the txt file.

Basically its a script to substitute a list of txt files for its zip equivalent but keeping the same name.

I’ve have used find to find the files that I want to zip:

find . -name '.txt.' -print

The Results are:

./InstructionManager.txt.0
./InstructionManager.txt.1

Those are the files I want to zip individually (of course they will be a lot more), but don’t know how to use them as arguments individually for make commans like:

zip ./InstructionManager.txt.0.zip ./InstructionManager.txt.0
mv ./InstructionManager.txt.0.zip ./InstructionManager.txt.0
zip ./InstructionManager.txt.1.zip ./InstructionManager.txt.1
mv ./InstructionManager.txt.1.zip ./InstructionManager.txt.1

Any Ideas? And no, i don’t want a zip with all the files :S
Thanks

  • 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-11T02:35:06+00:00Added an answer on June 11, 2026 at 2:35 am
    find . -name '*.txt.*' -print -exec zip '{}'.zip '{}' \; -exec mv '{}'.zip '{}' \;
    
    • Find the .txt files
    • The first -exec zips the files
    • The second -exec renames the zipped files to the original names

    Note that this procedure overwrites the original files. To be sure that the new files are actual zip files, you can do:

    file InstructionManager.txt.*
    

    Which should return:

    InstructionManager.txt.0: Zip archive data, at least v1.0 to extract
    InstructionManager.txt.1: Zip archive data, at least v1.0 to extract
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need to have a Shell script that will * Identify all the files [
I need a very simple shell script that processes all images on a folder
In a shell-script (or Perl) I need a subroutine that returns for all my
I need a shell command or script that converts a Unix timestamp to a
I need to write a Shell Script to process a huge folder of nearly
I need a shell script that deletes 1000 rows from a massive database until
I need to write a python script that launches a shell script and import
I would like a shell script that does a quick upload/download speed check of
I have a C shell script that calls two C programs - one after
Basically my problem is that I need to write a script that automatically creates

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.