[AWK] process field which ends with .dat


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [AWK] process field which ends with .dat
# 1  
Old 02-20-2008
[AWK] process field which ends with .dat

This is my first day with awk scripting..Please pardon my ignorance, if any..

I am trying to remove all files ending with .dat

ls -1R xyz/ | awk '$1==*.dat{print "rm " $1}' | bash

ls -1R --> will list files/directories one per line, even the sub directories

I try to match first field of line == *.dat , if true.. remove that file,i know I have not taken care of subdirectory... But that is what I am trying..Any idea how to do it..Smilie
# 2  
Old 02-20-2008
Maybe awk isn't the best method... Try this:

Code:
find xyz -type f -name "*.dat" -exec rm {}\;

For the first execution, omit the "-exec ..." part and check the output before removing anything!
# 3  
Old 02-21-2008
find

Code:
find . -name "*.dat" | xargs rm

# 4  
Old 02-21-2008
ls -1R *.dat | xargs rm
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to use 'ls' command to list files like *.dat, not *.*.dat?

How to use 'ls' command to list files like *.dat, not *.*.dat (5 Replies)
Discussion started by: pmcginni777
5 Replies

2. Shell Programming and Scripting

awk to update field using matching value in file1 and substring in field in file2

In the awk below I am trying to set/update the value of $14 in file2 in bold, using the matching NM_ in $12 or $9 in file2 with the NM_ in $2 of file1. The lengths of $9 and $12 can be variable but what is consistent is the start pattern will always be NM_ and the end pattern is always ;... (2 Replies)
Discussion started by: cmccabe
2 Replies

3. Shell Programming and Scripting

awk command on .DAT file not working?

Hi All, I am trying to run awk command on .DAT file and it is not working. The same command is working on .txt file: Contents of the file ZZ_55555555_444444_ZZZZZZ_7777777_888_99.DAT: HEADER|ZZ_55555555_444444_ZZZZZZ_7777777_888_99.DAT... (10 Replies)
Discussion started by: sagar.cumar
10 Replies

4. UNIX for Dummies Questions & Answers

ID incorrect field values in dat file and output to new file

Hi All I have a .dat file, the values are seperated by ". I wish to identify all field values in field 14 that are not '01-APR-2013' band then copy those records to a new file. Can anyone suggest the UNIX command required. Thanks in advance Andy (2 Replies)
Discussion started by: aurum1313
2 Replies

5. Shell Programming and Scripting

process field 1 depending on field 6

Hi I am abigginer to unix .I have a file which contains data like this . fiusdcanlt_fmrbgmusd1_run 07/23/2012 20:11:18 07/23/2012 20:12:20 SU 10861341/1 fiusdcanlt_fmrbgmusd2_run 07/23/2012 20:12:22 07/23/2012 20:21:26 SU 10861341/1 fiusdcanlt_fmrbgmusd3_run 07/23/2012... (7 Replies)
Discussion started by: ptappeta
7 Replies

6. OS X (Apple)

Script to process winmail.dat files in apple mail from outlook senders

Does anyone know of a way to automate the "massaging" of those STUPID winmail.dat files that come to Apple Mail extensions as a result from people sending mail from outlook clients? Specifically, something that would run when you attempt to open a winmail.dat file and auto extract and open... (2 Replies)
Discussion started by: herot
2 Replies

7. Shell Programming and Scripting

AWK: Pattern match between 2 files, then compare a field in file1 as > or < field in file2

First, thanks for the help in previous posts... couldn't have gotten where I am now without it! So here is what I have, I use AWK to match $1 and $2 as 1 string in file1 to $1 and $2 as 1 string in file2. Now I'm wondering if I can extend this AWK command to incorporate the following: If $1... (4 Replies)
Discussion started by: right_coaster
4 Replies

8. Shell Programming and Scripting

Remove interspersed headers in .dat file with AWK

Heya there, A small selection of my data is shown below. DATE TIME FRAC_DAYS_SINCE_JAN1 2011-06-25 08:03:20.000 175.33564815 2011-06-25 08:03:25.000 175.33570602 2011-06-25 ... (4 Replies)
Discussion started by: gd9629
4 Replies

9. Shell Programming and Scripting

awk, comma as field separator and text inside double quotes as a field.

Hi, all I need to get fields in a line that are separated by commas, some of the fields are enclosed with double quotes, and they are supposed to be treated as a single field even if there are commas inside the quotes. sample input: for this line, 5 fields are supposed to be extracted, they... (8 Replies)
Discussion started by: kevintse
8 Replies

10. Shell Programming and Scripting

Script - How to automatically start another process when the previous process ends?

Hi all, I'm doing automation task for my team and I just started to learn unix scripting so please shed some light on how to do this: 1) I have 2 sets of datafiles - datafile A and B. These datafiles must be loaded subsequently and cannot be loaded concurrently. 2) So I loaded datafile A... (10 Replies)
Discussion started by: luna_soleil
10 Replies
Login or Register to Ask a Question