Use command substitution like this:
line=$(sed -n '2p' myfile)
echo "$line"
Also note that there is no space around the =
sign.
More Related Contents:
- What does 2>&1 mean here?
- How to reload .bashrc settings without logging out and back in again?
- How do I iterate over a range of numbers defined by variables in Bash?
- When do we need curly braces around shell variables?
- How to loop through file names returned by find?
- How to manually expand a special variable (ex: ~ tilde) in bash
- Accessing bash command line args $@ vs $*
- Bash command line and input limit
- How can I escape a double quote inside double quotes?
- Tilde in path doesn’t expand to home directory
- When are square brackets required in a Bash if statement?
- Bash syntax error: unexpected end of file
- How to assign the output of a Bash command to a variable? [duplicate]
- Is there a TRY CATCH command in Bash
- Parsing variables from config file in Bash
- Bash variables with spaces
- Is it possible for bash commands to continue before the result of the previous command?
- How to remove (base) from terminal prompt after updating conda
- Retrieving multiple arguments for a single option using getopts in Bash
- grep for expression containing variable
- Stop on first error [duplicate]
- Is mixing getopts with positional parameters possible?
- Saving current directory to bash history
- How to check if running as root in a bash script
- Print a file’s last modified date in Bash
- How to escape the single quote character in an ssh / remote bash command?
- reverse the order of characters in a string
- What’s the cmd/PowerShell equivalent of back tick on Bash?
- Why doesn’t my terminal output unicode characters properly?
- In Bash test if associative array is declared