$ hg status
and
$ hg status --ignored
give very similar outputs. I'd like to concatenate them so I can feed them to awk, as if there were an hg status --all (or svn's svn status --no-ignore)
I'm thinking something like:
$ echo "$(hg status)" "$(hg status --ignored)" | awk ' ( $1 == "?" ) || ( $1 == "I") { print $2 }' | xargs rm -r
to make a 'make very clean indeed' command, but it seems to occasionally leave a file behind, perhaps because a newline goes missing or something.
Concatenate Commands With “&&“ The “&&” or AND operator executes the second command only if the preceding command succeeds.
You can make it do so by using the pipe character '|'. Pipe is used to combine two or more commands, and in this, the output of one command acts as input to another command, and this command's output may act as input to the next command and so on.
Use curly braces to group commands:
$ { echo first line; echo second line; } | grep "line" first line second line
(Posted as an answer from camh's comment)
You can use a subshell:
( hg status; hg status --ignored ) | awk '( $1 == "?" ) || ( $1 == "I") { print $2 }' | xargs rm -r
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With