I have below files in one directory. the file name has date and time portion which is exactly the file be created. I need keep only lasted created file which is abc_20140101_1550 and remove rest of the file.
You can simply use "ls -rt" to get your files sorted by date/time (instead of name) and then remove the last line (the latest file) and delete the others. Use the following blueprint:
ls -rt <optional file mask> |\
sed '$d'|\
while read FILE ; do
rm -f "$FILE"
done