Hi,
Can anyone please help me on building the logic for writing a shell script which can delete blank lines from a file and count the number of duplicate lines in a file.
Thanks,
Indra
Hi,
Can anyone please help me on building the logic for writing a shell script which can delete blank lines from a file and count the number of duplicate lines in a file.
Thanks,
Indra
Use sed command to delete blank lines.Then sort the file and use uniq command to find the duplicate count
#!/usr/bin/ksh
SPACE=" "
TAB=" "
WS="${SPACE}${TAB}"
typeset -i COUNT1=`cat file | grep -v "^[${WS}]$" | wc -l`
typeset -i COUNT2=`cat file | grep -v "^[${WS}]$" | sort -u | wc -l`
((DUPS=${COUNT1}-${COUNT2}))
echo "Number of duplicate lines: ${DUPS}"