Use eval:
x="ls | wc"
eval "$x"
y=$(eval "$x")
echo "$y"
More Related Contents:
- How to use ‘cp’ command to exclude a specific directory?
- How to limit user commands in Linux [closed]
- Run text file as commands in Bash
- Variable in Bash Script that keeps it value from the last time running
- sh: 1: Syntax error: "(" unexpected error
- Defining a variable with or without export
- Better way to rename files based on multiple patterns
- Convert date formats in bash
- Syntax error in shell script with process substitution
- Pipe to/from the clipboard in a Bash script
- What is the best way to ensure only one instance of a Bash script is running? [duplicate]
- Have bash script answer interactive prompts [duplicate]
- How to kill all processes with a given partial name? [closed]
- How do you find the original user through multiple sudo and su commands?
- Shell/Bash shortcut for bulk renaming of files in a folder
- How can I remove the last character of a file in unix?
- How to check if a file is empty in Bash?
- How to preserve line breaks when storing command output to a variable?
- How to use sed to remove the last n lines of a file
- Filename not printing correctly with underscore “_” in Bash [duplicate]
- Should PATH contain directories or full paths to binaries?
- Execute a command without keeping it in history [closed]
- The Bash command :(){ :|:& };: will spawn processes to kernel death. Can you explain the syntax?
- How do I run multiple background commands in bash in a single line?
- Add a newline only if it doesn’t exist
- Simple Socket Server in Bash?
- How do I get the difference between two dates under bash [duplicate]
- SUID not working with shell script
- Maximum number of Bash arguments != max num cp arguments?
- Using “$RANDOM” to generate a random string in Bash