How can I use the “nice” command with an alias?
As an example:
alias list=ls
list # works
nice -10 list # doesn't work
How could I make that last line work?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Alias is a shell feature, and
niceis an external program:It’s the program
nicethat runs the command passed as an argument, calling the C functionexecve, so all the arguments for it need to be evaluated BEFORE the call.So, it would probably better not to use an alias and simply put the whole command needed there, but if you really want to, you could try something like this:
alias listprints the alias definition in the formatalias list='ls'(orlist='ls', if it’s/bin/sh), so I did some sed substitutions there to get only the command it expands to.If you’re sure to use only
bashyou can use${BASH_ALIASES[list]}instead, as pointed out in the comments: