Vertical bar with rm

Closed
logan - 8 Nov 2009 à 20:04
jipicy Posts 40842 Registration date Wednesday 27 August 2003 Status Moderator Last seen 10 August 2020 - 9 Nov 2009 à 04:35
Hello,

1. I want to remove everything except test dirctory, why the following command don't work:
ls |grep -v test |rm -fr

2. According to manual, vertical bar get current program result and add it into the last position of next command, how to make the result into mid of next command, is there any auto variable can use?

1 response

jipicy Posts 40842 Registration date Wednesday 27 August 2003 Status Moderator Last seen 10 August 2020 17
9 Nov 2009 à 04:35
Hi,

ls |grep -v test |xargs rm -fr