For example, instead of:
( set -o posix ; set ) | grep -v '^PATH'| grep -v '^USER'
is there a way to do
( set -o posix ; set )
| grep -v '^PATH'
| grep-v '^USER'
within the .sh script itself (in order to make the code cleaner and easier to read?
Put the pipe at the end of the line instead of the beginning
( set -o posix ; set ) |
grep -v '^PATH' |
grep -v '^USER'
or escape the newlines
( set -o posix ; set ) \
| grep -v '^PATH' \
| grep -v '^USER'
If you use the second method, make sure there's no whitespace after the backslash, it has to be right before the newline.
Note that there's no need to use two grep calls. Use grep -E with a regexp that matches both variables.
( set -o posix ; set ) | grep -E -v '^(PATH|USER)'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With