In the just-released Bash 4.2, you can do this to prevent creating a subshell:
shopt -s lastpipe
Also, as you’ll probably see at the link Ignacio provided, you have a Useless Use of cat
.
while read -r line
do
...
done < afile
More Related Contents:
- 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?
- How to loop through file names returned by find?
- How can I pipe stderr, and not stdout?
- When are square brackets required in a Bash if statement?
- What is the meaning of the ${0##…} syntax with variable, braces and hash character in bash?
- What are the PowerShell equivalents of Bash’s && and || operators?
- Open and write data to text file using Bash?
- Send string to stdin
- Looping through alphabets in Bash
- How to rename with prefix/suffix?
- How to list variables declared in script in bash?
- Why is “[[ 10 < 2 ]]" true when comparing numbers in bash? [duplicate]
- Use awk to find average of a column [duplicate]
- Bash variable substitution vs dirname and basename
- How does one output bold text in Bash?
- How to go to each directory and execute a command?
- Is the behavior behind the Shellshock vulnerability in Bash documented or at all intentional?
- Pipe, standard input and command line arguments in Bash
- Why bash alias doesn’t work in scripts? [duplicate]
- How to bold one output text in Bash?
- pipe stdout and stderr to two different processes in shell script?
- Copy all files with a certain extension from all subdirectories
- Add numbers to the beginning of every line in a file
- How can I convert tabs to spaces in every file of a directory?
- Multiple commands in an alias for bash
- Casing arrow keys in bash
- How to iterate over list which contains whitespaces in bash
- How to use Bash to create a folder if it doesn’t already exist?
- What is more portable? echo -e or using printf?