Sponsored Content
Top Forums Shell Programming and Scripting Why doesn't "grep -w" ALWAYS work? Post 302602410 by turk22 on Monday 27th of February 2012 10:00:54 AM
Old 02-27-2012
More details

All, I apolgize for not replying sooner, for some reason, I was not recieving notification when there were replies..

Here is some more info regarding a larger snippet of the script, with some comments that I hope make it easier to understand:
************************************************
Code:
for i in `cat $ROUTERS`
do
devname=""
shortname=""
location=""
make=""
model=""
iosver=""
ifname=""
ifalias=""
mem=""
sernum=""
devname=$i
shortname=`echo $devname | cut -d "." -f 1`
location=`/opt/OV/bin/runsql location.sql | grep $devname | cut -d "|" -f 2 | awk '{print $1}'`
make=`/opt/OV/bin/runsql oem.sql | grep $devname | cut -d "|" -f 2 | awk '{print $1}'`
model=`/opt/OV/bin/runsql details.sql | grep $devname | cut -d "|" -f 3 | awk '{print $1}'`
iosver=`/opt/OV/bin/runsql details.sql | grep $devname | awk -F"Version" '{print $2}' | cut -d , -f 1`
mem="UnderConst"
sernum=`grep -i $devname /opt/OV/contrib/NNM/CBTS/data/sn.csv | cut -d "," -f 2`
/opt/OV/bin/runsql node_ifs.sql | grep $devname | cut -d "|" -f 2,5,6 > $WORKDIR/tmp_$shortname.tmp        
for i in `cat $WORKDIR/tmp_$shortname.tmp | awk '{print $1}'` 
## i is the IP address is this for loop ##
## So every time I grep for $i for the variables below, if $i was not uniquely found, then the corresponding variables are failing ##
## Each file for $WORKDIR/tmp/$shortname.tmp is the output given in the original post ##  
      do
        ifname=`/usr/xpg4/bin/grep -w $i $WORKDIR/tmp_$shortname.tmp | cut -d "|" -f 2 | awk '{print $1}'`
        ifalias=`/usr/xpg4/bin/grep -w $i $WORKDIR/tmp_$shortname.tmp | cut -d "|" -f 3 | tr ";" "-"`
        if [ $ifname = "Pseudo" ];then
          echo "Pseudo interface ....checking"
          location=`/usr/sfw/bin/snmpwalk -v2c -c decns $devname sysLocation.0 | cut -d ":" -f 4 | awk '{print $1}'`
          make=`/usr/sfw/bin/snmpwalk -v2c -c decns $devname  sysDescr.0 | head -1 | cut -d ":" -f 4 | awk '{print $1}'`
          model=`/usr/sfw/bin/snmpwalk -v2c -c decns $devname sysDescr.0 | head -1 | cut -d ":" -f 4 | cut -d , -f 2`
          iosver=`/usr/sfw/bin/snmpwalk -v2c -c decns $devname sysDescr.0 | head -1 | cut -d ":" -f 4 | cut -d , -f 3 | awk '{print $2}'`
        fi
        echo "$devname;$i;$ifname;$ifalias;$make;$model;$iosver;$location;$mem;$sernum" >> $REPORT
        #rm $WORKDIR/tmp_$shortname.tmp
        done
done

*****************************************************

thx,
SteveT

Last edited by jim mcnamara; 02-27-2012 at 11:09 AM.. Reason: please use code tags so we can read your code
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

my "case" doesn't work !

I'm using the case statement in the following script and it always takes the "*" default choice while it should be "3". I wonder why ??? dt_auj=`date +%d` NBLOG=`ls -al /users/notes01/LOG/t*|awk '{print $7}'|grep $dt_auj|wc -l` case $NBLOG in 1) cat ~/LOG/console-notes > $fic_tmp1 ;; 2)... (5 Replies)
Discussion started by: Nicol
5 Replies

2. UNIX for Dummies Questions & Answers

Why "@z=$x+$y" doesn't work?

253 lab2-36:~/try_direct/another> set x=1;set y=2;@z=$x+$y @z=1+2: Command not found. 254 lab2-36:~/try_direct/another> (11 Replies)
Discussion started by: endeavour1985
11 Replies

3. Linux

By angle-brackets/"pipe" button doesn't work?

How can I configure it? I have a swedish keyboard with swedish keyboard setting. Everything works perfectly (едц) except that button. What can be wrong? /Richard ++ NOTE: It seems like the computer notices the input but that the button isn't assigned to anything (the keyboard-cursor stops).... (1 Reply)
Discussion started by: riwa
1 Replies

4. UNIX for Advanced & Expert Users

sometimes "ps -elf" command doesn't work

when i give "ps -elf" or "ps" system gets hung. if i press "^c" come out from it... pls help..what should i do to get it resolved. thanks CKanth (4 Replies)
Discussion started by: srikanthus2002
4 Replies

5. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

6. UNIX for Dummies Questions & Answers

Help! "grep" doesn't work for me!

totally pis*ed off. I have a data set (xxx.txt), as follows: chr1 3821 rs127372 A/C 0.823 chr1 3822 rs127376 A/C/G 0.899 chr1 3722 rs612634 A/C 9.22 chr1 3262 rs7152 A/T 0.22 chr1 3711 rs737 A/C/G 0.2323 ....... I only want to get those lines... (6 Replies)
Discussion started by: kaixinsjtu
6 Replies

7. AIX

"/" doesn't work on command prompt for searching commands last typed

When I use "/" to look for a particular command that I typed in the current session it says D02:-/home/user1/temp> /job ksh: /job: not found. D02:-/home/user1/temp> previously it used to fetch all the commands which had job in it.. for example subjob, endjob, joblist etc... may I... (7 Replies)
Discussion started by: meetzap
7 Replies

8. AIX

AIX 5.3 on p275 - "|" key doesn't work (!)

More issues. The "|" key doesn't work at all, either in the text terminal or in mwm (which starts fine when I do "startx"). How am I supposed to troubleshoot without a "|" key? (2 Replies)
Discussion started by: smithfarm
2 Replies

9. Shell Programming and Scripting

Bash script: "mkdir -p" doesn't work with var(cat x)

Hello, :) I've an issue with the creation of a directory, All work without it :mad: So, below, my scripts with the debug output : #!/bin/bash # PATHS HOME_BACKUP="/home/backup" HOME_SCRIPT="/home/scripts/test/backup_server" TARGET="/var/www" # DATE DATE_Ymd=$(date +%Y-%m-%d) #... (1 Reply)
Discussion started by: Arnaudh78
1 Replies
largefile(5)                                            Standards, Environments, and Macros                                           largefile(5)

NAME
largefile - large file status of utilities DESCRIPTION
A large file is a regular file whose size is greater than or equal to 2 Gbyte ( 2**31 bytes). A small file is a regular file whose size is less than 2 Gbyte. Large file aware utilities A utility is called large file aware if it can process large files in the same manner as it does small files. A utility that is large file aware is able to handle large files as input and generate as output large files that are being processed. The exception is where additional files are used as system configuration files or support files that can augment the processing. For example, the file utility supports the -m option for an alternative "magic" file and the -f option for a support file that can contain a list of file names. It is unspecified whether a utility that is large file aware will accept configuration or support files that are large files. If a large file aware utility does not accept configuration or support files that are large files, it will cause no data loss or corruption upon encountering such files and will return an appropriate error. The following /usr/bin utilities are large file aware: adb awk bdiff cat chgrp chmod chown cksum cmp compress cp csh csplit cut dd dircmp du egrep fgrep file find ftp getconf grep gzip head join jsh ksh ln ls mdb mkdir mkfifo more mv nawk page paste pathchck pg rcp remsh rksh rm rmdir rsh sed sh sort split sum tail tar tee test touch tr uncompress uudecode uuencode wc zcat The following /usr/xpg4/bin utilities are large file aware: awk cp chgrp chown du egrep fgrep file grep ln ls more mv rm sed sh sort tail tr The following /usr/xpg6/bin utilities are large file aware: getconf ls tr The following /usr/sbin utilities are large file aware: install mkfile mknod mvdir swap See the USAGE section of the swap(1M) manual page for limitations of swap on block devices greater than 2 Gbyte on a 32-bit operating sys- tem. The following /usr/ucb utilities are large file aware: chown from ln ls sed sum touch The /usr/bin/cpio and /usr/bin/pax utilities are large file aware, but cannot archive a file whose size exceeds 8 Gbyte - 1 byte. The /usr/bin/truss utilities has been modified to read a dump file and display information relevant to large files, such as offsets. cachefs file systems The following /usr/bin utilities are large file aware for cachefs file systems: cachefspack cachefsstat The following /usr/sbin utilities are large file aware for cachefs file systems: cachefslog cachefswssize cfsadmin fsck mount umount nfs file systems The following utilities are large file aware for nfs file systems: /usr/lib/autofs/automountd /usr/sbin/mount /usr/lib/nfs/rquotad ufs file systems The following /usr/bin utility is large file aware for ufs file systems: df The following /usr/lib/nfs utility is large file aware for ufs file systems: rquotad The following /usr/xpg4/bin utility is large file aware for ufs file systems: df The following /usr/sbin utilities are large file aware for ufs file systems: clri dcopy edquota ff fsck fsdb fsirand fstyp labelit lockfs mkfs mount ncheck newfs quot quota quotacheck quotaoff quotaon repquota tunefs ufsdump ufsrestore umount Large file safe utilities A utility is called large file safe if it causes no data loss or corruption when it encounters a large file. A utility that is large file safe is unable to process properly a large file, but returns an appropriate error. The following /usr/bin utilities are large file safe: audioconvert audioplay audiorecord comm diff diff3 diffmk ed lp mail mailcompat mailstats mailx pack pcat red rmail sdiff unpack vi view The following /usr/xpg4/bin utilities are large file safe: ed vi view The following /usr/xpg6/bin utility is large file safe: ed The following /usr/sbin utilities are large file safe: lpfilter lpforms The following /usr/ucb utilities are large file safe: Mail lpr The following /usr/lib utility is large file safe: sendmail SEE ALSO
lf64(5), lfcompile(5), lfcompile64(5) SunOS 5.10 7 Nov 2003 largefile(5)
All times are GMT -4. The time now is 11:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy