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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:00:33+00:00 2026-05-28T13:00:33+00:00

At the moment here is what im doing ret=$(ls -la | awk ‘{print $3

  • 0

At the moment here is what im doing

ret=$(ls -la | awk '{print $3 " "  $9}')
usr=$(echo $ret | awk '{print $1}')
fil=$(echo $ret | awk '{print $2}')

The problem is that im not running an ls im running a command that takes time, so you can understand the logic.

Is there a way I can set the return value to set two external values, so something such as

ls -la | awk -r usr=x -r fil=y '{x=$3; y=$9}'

This way the command will be run once and i can minimize it to one line

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

    A workaround using read

    usr=""
    fil=""
    while read u f; do usr="$usr\n$u"; fil="$fil\n$f"; done < <(ls -la | awk '{print $3 " "  $9}')
    

    For performance issue you could use <<<, but avoid it if the returned text is large:

    while read u f; do usr="$usr\n$u"; fil="$fil\n$f"; done <<< $(ls -la | awk '{print $3 " "  $9}')
    

    A more portable way inspired from @WilliamPursell’s answer:

    $ usr=""
    $ fil=""
    $ while read u f; do usr="$usr\n$u"; fil="$fil\n$f"; done << EOF
    > $(ls -la | awk '{print $3 " "  $9}')
    > EOF
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm doing a lab at the moment working on fitness functions. The problem is
Ok, so here's my current setup and my problem at the moment. I have
I'm not sure what i'm doing wrong here. I've set up the environment variables...
My goal here is to create a very simple template language. At the moment,
I seem to be blind at the moment, so I need to ask here.
At the moment I'm doing this: gems(id, name, colour, level, effects, source) id is
At the moment, my footer ( found here ) is the same width as
I have this at the moment, (I found the code on here). var exp
I'm doing some codeacadamy courses at the moment. It's a great service, highly recommended.
Here's what I'm doing (it's my homework): the assignment is to make a map

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.