awk script to filter and delete
Hey guys! First off, thanks for any help you can provide me. I am trying to figure out how to write an awk script(or something better if it exists) to read a text file that contains lines like below.
4517-s-1295546289-10:58:09-2011-01-20.wav | 19990 KiB | 2940.5 KiB/s | binary | 100% 4517-s-1303247233-15:07:13-2011-04-19.wav | 167 KiB | 2918.3 KiB/s | binary | 100% 4517-s-1301431748-14:49:08-2011-03-29.wav | 36220 KiB | 2589.3 KiB/s | binary | 100% 4517-s-1295974735-09:58:55-2011-01-25.wav | 20038 KiB | 2646.0 KiB/s | binary | 100% 4517-s-1295648478-15:21:18-2011-01-21.wav | 45561 KiB | 2154.1 KiB/s | binary | 100% 4517-s-1300384178-11:49:38-2011-03-17.wav | 6752 KiB | 2216.0 KiB/s | binary | 100% I want to find lines that start with 4517-s and end with 100% and delete them from a directory. I am sorry, I just am too new to know where to even start. |
Also, I am not sure if I have posted this in the wrong place or not so if I have, please let me know and I will move it.
Thanks |
For example (with a) input file named list.in, b) no spaces in any wav files, c) directory where to delete files located in current directory and named sound) :
Code:
$ dir=sound |
First off thanks for your help. After looking at my file, I noticed that I can just go ahead and delete all files ending in 100% so I think I can just write this:
Code:
dir=/var/spool/asterisk/monitor |
Quote:
Code:
$ awk -vDIR=$dir ' /.*100%$/ { system("rm "DIR"/"$1) } ' output.txt See awk regexp at http://www.gnu.org/software/gawk/man...wk.html#Regexp |
Actually, you don't need the dot and star at all. This will work:
Code:
/100%$/ |
|
All times are GMT -5. The time now is 07:58 AM. |