I posted a similar question on StackOverflow (probably should have posted here on Unix & Linux).
My solution was to write a bash function:
xtrace() {
local eval_cmd
printf -v eval_cmd '%q' "${@}"
{ set -x
eval "${eval_cmd}"
} 2>&1 | grep '^++'
return "${PIPESTATUS[0]}"
}
So xtrace u
will print out something like:
++ apt-get update
++ apt-get upgrade -y --show-progress
++ apt-get autoremove -y
++ apt-get check
++ apt-get autoclean
Keep in mind that this actually executes whatever alias you pass to it, so if you don't want to execute u
, then @MichaelHomer's solution is the better way to go. Also, because of your &&
chain, if any one of the commands in your alias does not return 0, then execution will stop and you will only see the expanded aliases up to that point.
type u
and "These are all aliases inu
", what isu
? And isup && ap upgrade -y etc......
the command you are trying to execute? If yes, then can you tell us in what way it doesn't work? – Celada Jul 26 '14 at 10:36help unalias
. – Cyrus Jul 26 '14 at 10:38type
command says something about something sotype u
says something about alias namedu
The problem is it returns what the commandu
does but it contains more aliases. – user251046 Jul 26 '14 at 10:40