Finding missing tags


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Finding missing tags
# 1  
Old 04-29-2011
Finding missing tags

I have a list containing strings. All strings should have either "smp" or "drw" else it is considered an error. I have written this code below. Any better ideas to tackle this?

Code:
set fdrw = 0
set fsmp = 0
foreach f ($Lst)
  set fdrwtag = `echo $f | awk '/drw/'`
  set fsmptag = `echo $f | awk '/smp/'`
  if ($fdrwtag != "") set fdrw = 1  # Darwin tag detected.
  if ($fsmptag != "") set fsmp = 1  # Simplex tag detected.

  if (($fdrw == 0) && ($fsmp == 0)) then
    echo "\nERROR: $f  Does not contain 'drw' or 'smp'.\n"
    exit 1
  endif

  if (($fdrw == 1) && ($fsmp == 1)) then
    echo "\nERROR: $f  Contains both 'smp' and 'drw'.\n"
    exit 1
  endif
end

I have tried

Code:
set AierrLst = `echo $AfullNameLst | awk 'BEGIN {ORS="";RS=" "} !/drw|smp/'`
set nf = `echo $AierrLst | awk '{print NF}'`
if ($nf > 0) then
  foreach f ($AierrLst)
    echo "ERROR: $f  File name does not have 'smp' or 'drw' tag"
  end
endif

but I am getting

Code:
/drw: Event not found.

---------- Post updated at 02:41 PM ---------- Previous update was at 02:24 PM ----------

Fixed it, seems if I have a space after ! it works
Code:
set AierrLst = `echo $AfullNameLst | awk 'BEGIN {ORS=" ";RS=" "} ! /drw|smp/'`

# 2  
Old 04-29-2011
Not sure about csh, but no fork/execvp needed in sh/ksh/bash:
Code:
for s in $list
do
 case "$s" in
 (*drw*|*smp*)
   good-processing
   ;;
 (*)
   bad-processing
   ;;
 esac
done

Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Python BeautifulSoup Re Finding Digits Within Tags

I am writing a little python script that needs to grab version numbers between "<td>4.2.2</td>" within the tbody of the page: blah blah blah blah blah Is it possible to use a one-liner to scrap only the digits between the tags: "<td>4.2.2</td>" so it spits out: 4.2.2 4.2.1 etc..... (2 Replies)
Discussion started by: metallica1973
2 Replies

2. Shell Programming and Scripting

Finding missing records and Dups

I have a fixed width file. The records looks something similar to below: Type ID SSN NAME .....AND SOME MORE FIELDS A1 1234 ..... A1 1234 ..... B1 1234 ..... M2 4567 ..... M2 4567 ..... N2 4567 ..... N2 4567 ..... A1 9999 N2 9999 Now if A1 is present then B1 has to be present.... (2 Replies)
Discussion started by: Saanvi1
2 Replies

3. AIX

Need help finding missing drivers

I'm in the process of migrating a system to some newer hardware (Power 5 to Power 7). I've done these migrations in the past, and have not had any problems. But this system does not see the new network controllers on the Power 7 system. The system was running AIX 5.3 before, I've upgraded it to... (5 Replies)
Discussion started by: acascianelli
5 Replies

4. Shell Programming and Scripting

Finding tags in file names using csh

I have the following script and want to check if in each $f there exists either a "drw" or "smp" tag in the file name. How can I do it? For example npt06-32x24drw has the "drw" tag npt06-32x24smp has the "smp" tag npt06-32x24 no "drw" or "smp" tag found #!/bin/csh set iarg = 0... (0 Replies)
Discussion started by: kristinu
0 Replies

5. Shell Programming and Scripting

finding missing items in file

I have a need to compare 2 files, then print results to file. Need to find items from file2 that are not found in file 1. thanks in advance! example: file 1: abcde=12 fffff=6 bbbb=35 file2: abcde=12 fffff=6 bbbb=35 ccccc=10 kkkkk=45 (8 Replies)
Discussion started by: discostu
8 Replies

6. Shell Programming and Scripting

Finding missing files that are named sequentially with Perl?

Hello I am new to Perl, in fact I am on chapter one of the book. :) However I am in need of a Perl Script faster than I can finish the book. Perhaps someone can help me with my immediate need while I read my book. I have a directory with hundreds of files that are all named like... (4 Replies)
Discussion started by: newftronics
4 Replies

7. Shell Programming and Scripting

Finding missing sequential file names

So, I've got a ton of files that I want to go through (ie something like 300,000), and they're all labeled sequentially. However I'm not 100% positive that they are all there. Is there any way of running through a sequence of numbers, checking if the file is in the folder, if not appending it... (2 Replies)
Discussion started by: Julolidine
2 Replies

8. UNIX for Advanced & Expert Users

Finding which file is missing

I was hoping someone ould help me with the following. I have 2 files in a directory FILEA and FILEB. i am running a process on these 2 files but before the process can run both FILEA and FILEB need to be present. If one or both the files are missing i need to know what file(s) is(are)... (10 Replies)
Discussion started by: SAMZ
10 Replies
Login or Register to Ask a Question