3 ms·
> I don't think there is a way to do something like `exec {myvar}>file` I might be misunderstanding this, but piping to `save` is how you usually redirect to a
by ripley12 5y ago
> I don't think there is a way to do something like `exec {myvar}>file`
I might be misunderstanding this, but piping to `save` is how you usually redirect to a file in Nu: https://www.nushell.sh/book/commands/save.html https://www.nushell.sh/book/commands/save.html
- thayne 5y ago`exec {myvar}>file` will open a file descriptor that can write to `file`, and then store that file descriptor in the variable `$myvar`, so you can then redirect additional commands to it with `>$myvar` or `>>$myvar`. From the bash man page: > Each redirection that may be preceded by a file descriptor number may instead be preceded by a word of the form {varname}. In this case, for each redirection operator except >&- and <&-, the shell will allocate a file descriptor greater than or equal to 10 and assign it to varname. If &- or <&- is preceded by {varname}, the value of varname defines the file descriptor to close. If {varname} is supplied, the redirection persists beyond the scope of the command, allowing the shell programmer to manage the file descriptor himself.
- ripley12 5y agoThanks, I was misunderstanding.