Let's say I have
ls | xargs -n1 -p rm, how do I use
yes n to automatically answer the questions generated by the
yes n | (ls | xargs -n1 -p rm) but didn't work.
UPDATE: The question is not really about
rm, it's about how to use
yes properly. I have an alias or a function that uses
xargs -p and I like the fact that it asks me and shows me what it's doing before doing it. When I know what it will do, I would like to be able to use
yes to automatically go through all of the
xargs -p in the function. So even though the example uses
rm, it's not really about it.
Also just to be extra clear, I don't want to modify my alias or function to use or not use
-p. I rather just input yes externally.
Tbh I thought that something like
yes | some_function_asking_me_questions or
some_function_asking_me_questions <( yes ) would have worked, but it didn't.
2nd EDIT: Another example: I have an alias to list AWS SNS topics in a region like:
alias delete_snstopics="list_sns | cut -f 2 | xargs -n1 -p aws sns delete-topic --topic-arn "
Then I have a function that for each region in AWS finds and prompts for deletion for those SNS topics. I want to see the
aws sns delete-topic --topic-arn $1 that the xargs would run, because the id of the SNS topic is different every time and if something goes wrong I can match up the SNS id in the web console. Moreover at times I might not want to delete the SNS topic in a particular region. And that's why I want to use
yes with this function, so that I can use the same function for partial deletion and full deletion, and still get useful output. Makes sense?