echo file deleted by xargs


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting echo file deleted by xargs
# 1  
Old 04-10-2011
echo file deleted by xargs

my command deletes the oldest file from a folder and I'd like to have some type of output when the file is selected or deleted.
Code:
ls -t -1 | tail -n 1 | xargs rm

I'm not sure how to incorporate echo into this.

Thanks,

Last edited by Scott; 04-10-2011 at 07:56 PM..
# 2  
Old 04-10-2011
Depending on your OS, you might have the -v option for rm:

i.e.
Code:
... | xargs rm -v

# 3  
Old 04-10-2011
Thanks, that took care of he problem.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. What is on Your Mind?

Echo eval xargs and other siblings

It always seemed to me that these utils are siblings. All they do are that substitute values for variables, rearrange the parameters, and confuse the input with the output. :) I tried to display their main signature in table together. To show their similarities (3 Replies)
Discussion started by: nezabudka
3 Replies

2. Shell Programming and Scripting

Exec and xargs mvoe file to directory

Hello, I am trying to move all the file listed by below command to /tmp/testing directory find ./ -maxdepth 1 -type f -mtime +3 I tried using -exec and xargs - none of the combination is working? Please, help (3 Replies)
Discussion started by: saurabh84g
3 Replies

3. UNIX for Dummies Questions & Answers

Using xargs To Delete Yesterdays File

Using the find command to find files in a directory and automatically delete files older than 24 hours find . -mtime +0 | grep file | xargs rm. Using the find man page but I can't seem to make it work for files that have the previous day's time stamp but are not 24 hours old. Is there a way for... (4 Replies)
Discussion started by: jimmyf
4 Replies

4. Shell Programming and Scripting

Xargs or Find with output to a file

Hi, I've got to setup a script that will run daily, and find a log file of a certain age, and then compress and transfer this file to a new location. so far i've been able to specify the file i want with: find . -name 'filename.*.log' -mtime 14 -exec compress -vf {} \; this prints out... (4 Replies)
Discussion started by: horhif
4 Replies

5. UNIX for Dummies Questions & Answers

/dev/null a file using xargs

Hi, I'm currently using the following command to wipe clean a log file which can't be straight out RM'd: cat /dev/null > server.log I'm building this into a script and I'm current working on a command to run on each machine to do this automatically however I have multiple files so I need... (11 Replies)
Discussion started by: Deehem
11 Replies

6. Shell Programming and Scripting

File find | xargs grep for pattern file

Folks I've been struggling this with for far too liong now and need your help! I've been happily using grep for a search of a directory, to list the files which contain a string: find . -type f -mtime -5 -print | xargs grep -l 'invoiceID=\"12345\"' Now the list of 'invoiceID' I am... (4 Replies)
Discussion started by: daveaasmith
4 Replies

7. UNIX for Dummies Questions & Answers

'echo dir_path | xargs cd' does not work?

Hi: how come this command does not work? the error message is: xargs: cd: No such file or directory yet, in the same time, 'echo dir_path | xargs ls' works. Does it work in bash? We use csh. Thanks. NB Phil (7 Replies)
Discussion started by: phil518
7 Replies

8. Shell Programming and Scripting

Count words on each line in file using xargs

Hi, im having a problem with xargs, i want to cout word of each line in file, and i HAVE to use xargs, i tried: cat file | xargs wc -w .....that uses all words in file like name of files and passed then to wc so it worte wc :somewordformfile is not i afile or directory cat file | xargs -I{} wc... (3 Replies)
Discussion started by: Qwetek
3 Replies

9. UNIX for Dummies Questions & Answers

how to know who has deleted the file.

Hi, We have a file which needs supper user previleges to delete. There are 10 users having super user preveleges. Some times back that file got deleted. How to know who has deleted that file? (6 Replies)
Discussion started by: siba.s.nayak
6 Replies

10. Shell Programming and Scripting

Xargs command outupt to file

Hello, I'm on a mac trying to have the follow cmd list the files after touch, but very unsuccessful. Please can you help. sort $BOTHFILE | uniq -u | xargs -I {} -t touch {} >> $LOGFILE ; BOTHFile contents in form of /directory/file.txt thanx (3 Replies)
Discussion started by: byblos
3 Replies
Login or Register to Ask a Question