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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:25:25+00:00 2026-05-23T16:25:25+00:00

Trivial question. #!/bin/bash if test -z $1 then echo No args! exit fi for

  • 0

Trivial question.

#!/bin/bash

if test -z "$1"
then
  echo "No args!"
  exit
fi

for newname in $(cat $1); do
  echo $newname
done

I want to replace that echo inside the loop with array population code.
Then, after the loop ends, I want to read the array again and echo the contents.
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-05-23T16:25:26+00:00Added an answer on May 23, 2026 at 4:25 pm

    If the file, as your code shows, has a set of files, each in one line, you can assign the value to the array as follows:

    array=(`cat $1`)
    

    After that, to process every element you can do something like:

    for i in ${array[@]} ; do echo "file = $i" ; done
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may seem a trivial question, but it's one that's bothered me a lot
Disclaimer, I'm not a PHP programmer, so you might find this question trivial. That's
Apologies for this trivial question, I'm new to WPF and keep finding blogs that
Probably a trivial question, but I want to get the best possible solution. Problem:
Ok I know that this is trivial question but: How can i remove lines
this is a very trivial question. but Eclipse IDE is telling me that it
Perhaps this is a trivial question, however it's something that is seriously annoying me.
Rather Trivial Question. So I tried to do this: if (array[0]==some_string) where array is
Sorry for such a trivial question, but I'd feel silly building this if it
A pretty silly trivial question. The canonical example is f = open('filename') , but

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.