Help required on building the logic


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help required on building the logic
# 1  
Old 01-11-2007
Help required on building the logic

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
# 2  
Old 01-11-2007
Use sed command to delete blank lines.Then sort the file and use uniq command to find the duplicate count
# 3  
Old 01-21-2007
#!/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}"
Login or Register to Ask a Question

Previous Thread | Next Thread

4 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help required in Building an XML using SAX Parser in perl

I want to use sax parser for my application as i have 5 Lakhs of data. I have the xml file like this <Nodes> <Node> <NodeName>Company</NodeName> <File>employee_details.csv</File> <data>employee_data.txt</data> <Node> <NodeName>dummy</NodeName> ... (8 Replies)
Discussion started by: vanitham
8 Replies

2. Shell Programming and Scripting

Logic in Shell script required

Hi, I have the following in my shell script sqlplus << EOF username/password @$SCRIPTS_DIR/refresh.sql > /home/oracle/sql/refreshsql.log EOF RETCODE=$? if ; then echo "ERROR: sqlplus command finished with error code {RETCODE}" /usr/bin/mailx -s "REFRESHING FMLA CONTACT... (2 Replies)
Discussion started by: welldone
2 Replies

3. Shell Programming and Scripting

URGENT SCRIPT LOGIC required

Hello friends, It will be great if we found some way to check this our: we have some databases (teradata and oracle). our applications(in java on weblogic) are using connection pools of these databases. we have a pair of userID and password for every pool. If we have any logic to test... (2 Replies)
Discussion started by: NIMISH AGARWAL
2 Replies

4. Shell Programming and Scripting

Help building the logic for a script

Hi guys, I am new to shell scripting, i need your help to tackle a problem. I have a single file, sample is below: 2008:07:08 07:01:14.360 (tid 4) INFO no bonus notifications to send 2008:07:08 07:01:50.823 (tid 1) INFO Database cleaned of all stale bonus records order than 30 days... (3 Replies)
Discussion started by: fahadaizaz
3 Replies
Login or Register to Ask a Question