Since I need to set and use alias in the same line in bash, I would like to use Hauke Laging's workaround:
eval 'alias df5=df
df5 -h'
(I took df
and df5
for the sake of the example. I am aware that in this specific example one could replace the entire eval
command by df -h
.)
However I would prefer to write this command into one line.
How can I write an eval
command containing a new line into one line?
I unsuccessfully tried the following one-line commands:
eval 'alias df5=df\ndf5 -h'
. Error-bash: alias: -h: not found
alias df5=df ; df5
. Error:No command 'df5' found
alias df5=df && df5
(suggested by Cyrus). Error:No command 'df5' found