- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- script to delete macthing lines
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2002 08:46 AM
04-12-2002 08:46 AM
original file
xyz123abc
ghi567zxc
ghi567zxc
abc345000
...
...
output file
xyz123abc
abc345000
...
...
The file is sorted do anybody have any script to do that?
Thanks in advacne
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2002 08:47 AM
04-12-2002 08:47 AM
Re: script to delete macthing lines
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2002 08:51 AM
04-12-2002 08:51 AM
Re: script to delete macthing lines
Thanks anyway
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2002 08:54 AM
04-12-2002 08:54 AM
Re: script to delete macthing lines
cat original | sort -u > tempfile
diff original tempfile > output_file
john.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2002 08:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2002 08:55 AM
04-12-2002 08:55 AM
Re: script to delete macthing lines
Here is a simple shell script to strip duplicate lines in a file ...
-------------------
#!/bin/sh
# dup - Will search for duplicate lines in a file
if [ -z "$1" ]; then
echo
echo "syntax: dup [filename]"
echo
exit
fi
file=$1
echo -n "Searching Dups..."
cat /dev/null > $file.n
while read line
do
found=`grep "$line" $file.n`
if [ -n "$found" ]; then
echo -n "."
else
echo "$line" >> $file.n
fi
done < $file
old=`wc -l $file | awk '{ print $1 }'`
new=`wc -l $file.n | awk '{ print $1 }'`
echo "`expr $old - $new` dups found"
echo "Newfile: $file.n"
--------------
Syntax is:
prompt>scriptname
Thanks,
Shabu