is there any way of using rm command on output of pipe


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers is there any way of using rm command on output of pipe
# 1  
Old 05-26-2011
is there any way of using rm command on output of pipe

Hi,

I am having a list of directories with different login id's. My requirement is that i need to list the directories of my id and need to delete them. So i am using following code

Code:
ls -ltr ¦ grep userid ¦ rm -rf

But this is not working. So is there any way of doing it. Please note that i need to run this code or any other alternative code in one line only.

Last edited by vbe; 05-26-2011 at 01:23 PM.. Reason: code tags almost good...(Slash not back slash...)
# 2  
Old 05-26-2011
Code:
find . -type d -uid $(id -u) -exec rm -fr {} \;

# 3  
Old 05-26-2011
or:
Code:
rm $(ls -lrt .|grep "userid"|awk '{print $9}')

# 4  
Old 05-26-2011
Code:
ls -ltr ¦ grep userid ¦ xargs rm -rf

 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get the output of w command in pipe delimited format

Since output of w command have variable number of columns I want to get the output in pipe delimited format. I tried export OFS="|"; w but that does not work. Any ideas? (4 Replies)
Discussion started by: Soham
4 Replies

2. SuSE

Find command doesn't pipe the output as required.

Hi, I am using below code snippet to echo/display the files found (matching a pattern from searchstring.out file) and the corresponding owner. while read j do echo "Pattern to search is:- $j" find / -name "*$j*" |\ while read k do echo "File found is:- $k" owner=$(ls... (9 Replies)
Discussion started by: Vipin Batra
9 Replies

3. Shell Programming and Scripting

How to pipe command output to shell script?

Hi Team, Need a help on how to pipe a command out put to a shell script. My shell script looks like below. cat shell_script #!/usr/bin/ksh input =$@ echo " we are inside the shell script" echo " here are the input parameters" .......................... .................. ... (11 Replies)
Discussion started by: gvkumar25
11 Replies

4. Shell Programming and Scripting

sed command to replace a line in a file using line number from the output of a pipe.

Sed command to replace a line in a file using line number from the output of a pipe. Is it possible to replace a whole line piped from someother command into a file at paritcular line... here is some basic execution flow.. the line number is 412 lineNo=412 Now i have a line... (1 Reply)
Discussion started by: vivek d r
1 Replies

5. Shell Programming and Scripting

Pipe output a command to another using xargs

xargs work great when a command gives multiple line output which can be input to another. In my case it is not working coz the second command uses two words in it. $ scr.sh gives output like 193740 638102 375449 .. .. another command takes these number as inputs. it works great... (1 Reply)
Discussion started by: mahesh113
1 Replies

6. Shell Programming and Scripting

Pipe delimited output

Hi All, i have the following command df|awk '{print $5}'|grep /| egrep -v '^/$|/usr|/opt|/var/log|/home|/tmp' output looks like: /filesystem/number1 /filesystem/number2 /filesystem3 /possiblymoreoutput i want the output to look like the below (either in a file or to output to... (3 Replies)
Discussion started by: Tommyk
3 Replies

7. UNIX for Dummies Questions & Answers

pipe > output

I can use pipe output to a file. For example ./somescript.sh > output.txt But for example if the output from ./somescript.sh is slow. like if it prints one line every minute then output.txt is not updated every minute. Lines are written to output.txt in one go, hence have to wait for the whole... (2 Replies)
Discussion started by: kevincobain2000
2 Replies

8. Shell Programming and Scripting

Assign command (with pipe) output to a variable

Hi , I would like to assign command (with pipe) output to a variable. The code is as follows. The goal of the code is to get the last folder folder with a particular name pattern. myDate=`ls | grep 2009 | tail -1` echo "myDate=" $myDate However, in the presence of the pipe, the code... (3 Replies)
Discussion started by: jeff_cen
3 Replies

9. UNIX for Dummies Questions & Answers

pipe output to script as command line argument

i want to redirect output of one command as the command line argument of another script for example, say i would run this command: find . -xdev -type f -size +4096 -exec ls -al {} \; i wan to be able to do something like: echo +4096 | find . -xdev -type f -size ****** -exec... (3 Replies)
Discussion started by: IMTheNachoMan
3 Replies
Login or Register to Ask a Question