Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I want to grep a file that will only output the content of the file which meet the following conndition:
File Content
=============
emalon
emalonv1
emalonv2If i want "emalon" to be grepped and outputted and not "emalonv1" and "eamlonv2", what will be the syntax.
King Regards
Junes

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

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 Regards
Junes

Its not a typo, file cat $LASTFAILEDDRIVE_Drive contains the following
File Content
=============
Dr306 emalon
Dr309 emalonv1
Dr301 emalonv2Any 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 Regards
Junes

# 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

#! /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/lastfaileddrivefor 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

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |