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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:29:24+00:00 2026-06-18T03:29:24+00:00

I want to put the output of command in bash variable and then further

  • 0

I want to put the output of command in bash variable and then further use that variable in other command

Suppose i want something like this

ls | $(variable) |awk '/$variable/{print "here"}'

  • 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-18T03:29:26+00:00Added an answer on June 18, 2026 at 3:29 am

    You can try:

    variable=$(ls); awk "/$variable/"'{print "here"}'
    

    Note 1: /$variable/ is surrounded by double quotes, otherwise it won’t be replaced by output of command.

    Note 2: The above command may fail since the output of ls may contains “/” or newline, which will break the awk command. You may change ls to something like ls | tr '\n' ' ' | tr -d '/' | sed 's/ *$//g'(replace all newlines with spaces; delete all slashes; remove the trailing whitespace), depending on your goal.

    Note 3: to avoid variable assignment polluting the current shell’s environment, you can wrap the above command by parentheses, i.e. (variable=$(some_command); awk "/$variable/"'{print "here"}')

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

Sidebar

Related Questions

I want to put the output of an cmd-command (e.g. assoc) into a textbox.
I want to put the output of GNU/Linux date command in a character array.
I need some help writing a command that will be put into a .sh.
I want to run lmutil.exe with the arguments -a, -c, and 3400@takd, then put
I want to put random output from my result set (about 1.5 mil rows)
I want to compile this PL/SQL program in the SQL window that belongs to
I've just discovered that in my course, the lecturer doesn't want us to use
I want to run the following bash command in Python 3: ls -l I
So I am trying to store the output of a command into a variable.
I want to use DBMS_OUTPUT.PUT_LINE , but the number of rows exceeds just 1.

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.