Worth a read and not blocked at Aramco
sed ‘x; G; /^\(.*\)\n\1$/ d; g; p; d’
Instead of this:
sed ‘$!N; /^\(.*\)\n\1$/!P; D’
The whole file does not have to be read into memory so you can do this on very large files.
$ read -r a b c d < $HOME/txt
$ printf “%s\n” “a=$a” “b=$b” “c=$c” “d=$d”
The order of redirection is important. Redirection is implemented at the stage at which it is executed.
./cmd 1>errors 2>&1
will record everything to errors.
.cmd 2>&1 1>errors
will send stderr to the terminal and stdout to the file errors.