Hello - Have a big issue need help please ASAP


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Hello - Have a big issue need help please ASAP
# 1  
Old 04-04-2011
Hello - Have a big issue need help please ASAP

I have been using this simple grep command to extract fields from a file that ALPHANUMERIC field has been set to 16
Code:
grep  -w 'ALPHANUMERIC     *16'  filename

------------------------- sample data file
Code:
SAMP_RICS  "SAMPLE RICS"        5694  NULL        ALPHANUMERIC       60  RMTES_STRING    60
PROB_DESC  "PROBLEM DESC"       5695  NULL        ALPHANUMERIC       32  RMTES_STRING    32
PAIR_CLIP1 "PAIR CLIP1"         5702  NULL        ALPHANUMERIC        9  RMTES_STRING     9
RELDATA1   "RELATED DATA1"      5756  NULL        ALPHANUMERIC       16  RMTES_STRING    16
RELNEWS    "RELATED NEWS"       5757  NULL        ALPHANUMERIC       16  RMTES_STRING    16
RELDATA2   "RELATED DATA2"      5758  NULL        ALPHANUMERIC       21  RMTES_STRING    21

--------------------------------------------

What I need to do is to extract everyline where the ALPHANUMERIC is set t to 28 and higher? betweem 28 & 255 t obe exact
I tried this shell script but it is not working. The grep command fails
because $c is not interperted ..
I tried escape character and it did not work


Anyone can help me with a simple shell command to extract all lines where the ALPHANUMERIC is set to 28 or higher?
Code:
#!/bin/bash

c=28
while [ $c -ge 28 ]  ; [ $c -le 255 ]
do
        grep -w 'ALPHANUMERIC     $c' RDMFieldDictionary
        (( c++ ))
done

~


------------------- Question --??


Anyone can help me with a simple shell command to extract all lines where the ALPHANUMERIC is set to 28 or higher in this file?

Last edited by Franklin52; 04-04-2011 at 02:09 PM.. Reason: Please use code tags
# 2  
Old 04-04-2011
Try:
Code:
awk '$7>=28' file

# 3  
Old 04-04-2011
Thanks but awk does not work because the colums are not all equal or I should say somehow they don;t match up
# 4  
Old 04-04-2011
awk can still be used, you just have to check where ALPHANUMERIC is.

grep certainly can't be used, or at least not easily. grep doesn't understand numerics at all.

Code:
awk '{
for(N=1; N<=NF; N++)
{
       if($N == "ALPHANUMERIC")
       {
               N++;
               if(($N >= 28) && ($N  <= 255)) print;
       }
}' < infile

# 5  
Old 04-04-2011
Try this,
Code:
 perl -nle 'print if(/ALPHANUMERIC\s+(2[89]|[3-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/)' infile

# 6  
Old 04-04-2011
we do not have perl on the system thanks

---------- Post updated at 12:13 PM ---------- Previous update was at 12:13 PM ----------

corona688 the code u provided that goes inside a script
# 7  
Old 04-04-2011
The length of the column can change, but maybe there are no adding space in the last 3 columns ... if so, you can then just go with this :

Just give a try :

Code:
awk '$(NF-2)>27' infile

this can easily be enforced like

Code:
awk '/ALPHANUMERIC/&&$(NF-2)>27&&$(NF-2)<256' infile

Code:
# awk '/ALPHANUMERIC/&&$(NF-2)>27&&$(NF-2)<256' tst
SAMP_RICS  "SAMPLE RICS"        5694  NULL        ALPHANUMERIC       60  RMTES_STRING    60
PROB_DESC  "PROBLEM DESC"       5695  NULL        ALPHANUMERIC       32  RMTES_STRING    32


Last edited by ctsgnb; 04-04-2011 at 02:22 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Delete big directory issue

Hello folks, I am deleting a directory with script it is taking 11Hour and also increase the IO on server. I am using below command, inside date directory there are hour directories, which i am deleting after archiving. Archiving is not taking long time, only "rm -rf" is taking alot of time with... (21 Replies)
Discussion started by: learnbash
21 Replies

2. Solaris

Big /etc/group creating issue

I have Solaris-10 with kernel patch 142900-03, Update 7 Sparc server. root@ddlomps40:/# uname -a SunOS ddlomps40 5.10 Generic_142900-03 sun4u sparc SUNW,SPARC-Enterprise root@ddlomps40:/# cat /etc/release Solaris 10 5/09 s10s_u7wos_08 SPARC Copyright 2009 Sun... (5 Replies)
Discussion started by: solaris_1977
5 Replies

3. Red Hat

NFS4 Mount issue - ASAP

Hi, I am trying to mount via nfs4 # mount -t nfs4 10.1.56.16:/Apps /works/apps/xyz Error: Warning rpc.idmapd apperas not to be running all uids will be mapped to the nobody uid mount to NFS server "10.1.56.16' failed RPC error: program/version mismatched pls help - this is coming... (1 Reply)
Discussion started by: saurabh84g
1 Replies

4. Homework & Coursework Questions

PLEASE HELP ME ASAP

can anyone help me with this??? make program ( shell script) to detect and display errors occurred in initializing a Unix system (4 Replies)
Discussion started by: dementor
4 Replies

5. UNIX for Dummies Questions & Answers

How big is too big a config.log file?

I have a 5000 line config.log file with several "maybe" errors. Any reccomendations on finding solvable problems? (2 Replies)
Discussion started by: NeedLotsofHelp
2 Replies

6. Shell Programming and Scripting

need help asap!

Hello everyone, I'm new to using Linux and i am trying to create a script that will produce a list of all the files of the present working directory. So far I only have this #!/bin/bash cd / ls -lt>> I can't figure out what I am suppose to do next. (6 Replies)
Discussion started by: reecygee
6 Replies

7. Shell Programming and Scripting

need help asap

i have a file having content a|b|c 1|2|33 4|6|55 end a|b|d 3|4|55 end a|b|c 45|67|98 end so i want to print 3rd field of header a|b|c and footer end. e.g. o/p should be 33 55 98 (7 Replies)
Discussion started by: manas_ranjan
7 Replies

8. UNIX for Dummies Questions & Answers

How to view a big file(143M big)

1 . Thanks everyone who read the post first. 2 . I have a log file which size is 143M , I can not use vi open it .I can not use xedit open it too. How to view it ? If I want to view 200-300 ,how can I implement it 3 . Thanks (3 Replies)
Discussion started by: chenhao_no1
3 Replies
Login or Register to Ask a Question