Shell Script Which Will Discards All But One of Successive Identical

in Categories Academic, File-management last updated October 20, 2008
# Write the shell program unique, which will discards all but one of successive
# identical 
# --------------------------------------------------------------------
# This is a free shell script under GNU GPL version 2.0 or above
# Copyright (C) 2005 nixCraft project.
# Feedback/comment/suggestions :
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit for more information.
# -------------------------------------------------------------------------
echo -n "Enter file name : "
read file
if [ ! -f $file ]
	echo "Not a file"
	exit 1
uniq $file

Share this on:

1 comment

  1. Is this supposed to teach me about read, uniq or the test command? What s the advantage of creating this script, making it executable and running it instead of just doing uniq ? Why not just read the uniq man page?

    You didn’t really _write_ anything if you use the uniq program in the script.

Leave a Comment