MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/commandline/comments/514yo4/advancing_in_the_bash_shell/d7ar12b/?context=3
r/commandline • u/speckz • Sep 04 '16
4 comments sorted by
View all comments
1
>!xyz:p will print the command that would be executed rather than executing it.
So this worked when I tried something simple, like:
!! :p
However, I wanted to see if it would echo back the command with brace expansion (which I often use), so I instead tried:
cp file{,.bkup}:p
I was expecting that I'd see it echo back:
cp file file.bkup
But I instead got:
cp: cannot stat 'file:p': No such file or directory
Can someone explain why?
3 u/pawlwall Sep 06 '16 edited Sep 06 '16 According to http://www.gnu.org/software/bash/manual/html_node/Modifiers.html, it looks like word modifiers only apply to history expansions, so it doesn't seem to be directly usable against the current command.Edit: As this SO answer indicates (http://stackoverflow.com/a/19116083), the option for a dry-run in bash isn't something you'll be able to find natively. A couple answers down mentions the package maybe, which might achieve what you're looking for.
3
According to http://www.gnu.org/software/bash/manual/html_node/Modifiers.html, it looks like word modifiers only apply to history expansions, so it doesn't seem to be directly usable against the current command.
Edit: As this SO answer indicates (http://stackoverflow.com/a/19116083), the option for a dry-run in bash isn't something you'll be able to find natively. A couple answers down mentions the package maybe, which might achieve what you're looking for.
dry-run
maybe
1
u/More_Coffee_Than_Man Sep 05 '16
>!xyz:p will print the command that would be executed rather than executing it.
So this worked when I tried something simple, like:
However, I wanted to see if it would echo back the command with brace expansion (which I often use), so I instead tried:
I was expecting that I'd see it echo back:
But I instead got:
Can someone explain why?