I have to delete files of yesterday, I am doing something like this
ls -l | grep 'Feb 15'|awk| xargs
I cant use awk, since my file names have spaces in them, so I cant separate them in the output of ls -l.
Can anyone help me with this?
This question came from our site for professional and enthusiast programmers.
to make sure you're seeing the proper results -mtime n means n*24 hours ago then use -print0 to work around spaces
then to remove add a pipe to xargs
I am basing my answer on the fact that you're having trouble handling file names with spaces in them.
I have a Linux application that has to deal with files whose names contain embedded spaces. The following are extracts from my bash shell script that allow me to use a for loop to find the two files and do something about them.
In my case, it was to pass them off to a Clojure program that would identify what the files were based on their column signatures. Both files are .csv files. The money shot is changing IFS, and then restoring its original value when you are done. That allows $fnam to contain the file name if it has embedded spaces in it.