Only grep a particular string
|
Original Message
|
Name: Junes
Date: July 6, 2006 at 09:30:05 Pacific
Subject: Only grep a particular stringOS: unixCPU/Ram: naModel/Manufacturer: na |
Comment: I want to grep a file that will only output the content of the file which meet the following conndition: File Content ============= emalon emalonv1 emalonv2 If i want "emalon" to be grepped and outputted and not "emalonv1" and "eamlonv2", what will be the syntax. King RegardsJunes
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: nails
Date: July 6, 2006 at 10:05:24 Pacific
Subject: Only grep a particular string |
Reply: (edit)Sine your file only has 3 lines, this regular expression works: grep 'emalon$' data.file The above works because it searches for emalon at the end of a line. If your grep supports the word option, -w, this works: grep -w 'emalon' data.file
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: Junes
Date: July 7, 2006 at 07:32:34 Pacific
Subject: Only grep a particular string |
Reply: (edit)More advice please I can't get the following expression to provide the correct output. LastFDrive=`cat $LASTFAILEDDRIVE_Drive | awk '{print $1}' | grep -w $DriveName` + + cat /usr/openv/netbackup/BOA_scripts/temp_files/lastfaileddrive + grep -w Dr305 + awk {print $1} LastFDrive= + + grep -w emalonvme00v1 + cat /usr/openv/netbackup/BOA_scripts/temp_files/lastfaileddrive + awk {print $2} LastFServer= If i run via CLI, it works cat $LASTFAILEDDRIVE_Drive | awk '{print $1}' | grep -w $DriveName Can someone provide some advice King RegardsJunes
Report Offensive Follow Up For Removal
|
|
Response Number 4
|
Name: Junes
Date: July 10, 2006 at 03:25:29 Pacific
Subject: Only grep a particular string |
Reply: (edit)Its not a typo, file cat $LASTFAILEDDRIVE_Drive contains the following File Content ============= Dr306 emalon Dr309 emalonv1 Dr301 emalonv2 Any adivce please for the following question!!!!! ----------
More advice please I can't get the following expression to provide the correct output. LastFDrive=`cat $LASTFAILEDDRIVE_Drive | awk '{print $1}' | grep -w $DriveName` + + cat /usr/openv/netbackup/BOA_scripts/temp_files/lastfaileddrive + grep -w Dr305 + awk {print $1} LastFDrive= + + grep -w emalonvme00v1 + cat /usr/openv/netbackup/BOA_scripts/temp_files/lastfaileddrive + awk {print $2} LastFServer= If i run via CLI, it works cat $LASTFAILEDDRIVE_Drive | awk '{print $1}' | grep -w $DriveName King RegardsJunes
Report Offensive Follow Up For Removal
|
|
Response Number 6
|
Name: Junes
Date: July 10, 2006 at 07:16:57 Pacific
Subject: Only grep a particular string |
Reply: (edit)# cat /usr/openv/netbackup/BOA_scripts/temp_files/lastfaileddrive >> - Dr306 emalon # cat /usr/openv/netbackup/BOA_scripts/temp_files/lastfaileddrive | awk '{print $1}' | grep -w Dr306 >> - Dr306 # cat /usr/openv/netbackup/BOA_scripts/temp_files/lastfaileddrive | awk '{print $2}' | grep -w emalon >> - emalon But when i run the command via the script, i do not get the output that i require. LastFDrive=`cat $LASTFAILEDDRIVE_Drive | awk '{print $1}' | grep -w $DriveName` + + cat /usr/openv/netbackup/BOA_scripts/temp_files/lastfaileddrive + grep -w Dr305 + awk {print $1} LastFDrive= + + grep -w emalonvme00v1 The following syntax is incorrect,
LastFDrive=`cat $LASTFAILEDDRIVE_Drive | awk '{print $1}' | grep -w $DriveName`
I need advice.!!!!! King RegardsJunes
Report Offensive Follow Up For Removal
|
|
Response Number 8
|
Name: Junes
Date: July 11, 2006 at 01:13:54 Pacific
Subject: Only grep a particular string |
Reply: (edit)#! /bin/ksh touch /tmp/drive_status touch /tmp/drivetest.txt BPSTORAGEUNIT=/usr/openv/netbackup/bin/admincmd DRIVESTATUS=/usr/openv/volmgr/bin LASTFAILEDDRIVE_Drive=/usr/openv/netbackup/BOA_scripts/temp_files/lastfaileddrive for SERVER in `$BPSTORAGEUNIT/bpstulist | awk '{print $3}' | sort -u` do echo "SERVER NAME IS:=> $SERVER" $DRIVESTATUS/vmoprcmd -h $SERVER | grep -i DOWN | awk '{print $1,$3}' | while read LINE do IGNORE=NO DriveIndex=`echo $LINE | cut -f1 -d" "` DriveStatus=`echo $LINE | cut -f2 -d" "` DriveName="" DriveName=`$DRIVESTATUS/vmoprcmd -h $SERVER -d ad | awk '$1=='$DriveIndex' {print $2}'` if [ $DriveStatus = "DOWN" ] || [ $DriveStatus = "DOWN-ACS" ] || [ $DriveStatus = "DOWN-AVR" ];then # Check to see Failure Notification has not already been submmitted LastFDrive=`cat $LASTFAILEDDRIVE_Drive | awk '{print $1}' | grep -w $DriveName` LastFServer=`cat $LASTFAILEDDRIVE_Drive | awk '{print $2}' | grep -w $SERVER` if [ $LastFDrive != "" ] && [ $LastFServer != "" ] then continue; else King RegardsJunes
Report Offensive Follow Up For Removal
|

|

|
Use following form to reply to current message: