Vertical bar with rm

Closed
logan - Nov 8, 2009 at 08:04 PM
jipicy Posts 40842 Registration date Wednesday August 27, 2003 Status Moderator Last seen August 10, 2020 - Nov 9, 2009 at 04:35 AM
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 August 27, 2003 Status Moderator Last seen August 10, 2020 17
Nov 9, 2009 at 04:35 AM
Hi,

ls |grep -v test |xargs rm -fr 

0