Normalize a PATH-Style List

LinuxBeginner
Practice Now

Introduction

A configuration export stores directory names on one colon-separated line and repeats some entries. A normalized list is easier to inspect and compare.

This challenge combines only text-processing commands already introduced: translate a delimiter, sort lines, remove adjacent duplicates, and save the result.

Create the Normalized Directory List

Current Situation

/home/labex/project/path-audit/configured-path.txt contains one colon-separated line. Some directory strings occur more than once.

Scope

  • Convert each colon-separated entry into its own line.
  • Sort the lines alphabetically.
  • Keep each distinct directory string once.
  • Save the result as path-directories.txt.

Your Goal

Create one sorted, duplicate-free directory list.

Acceptance Criteria

  • path-directories.txt contains the four distinct source directory strings, one per line.
  • The lines are alphabetically sorted.
  • The source file remains unchanged.

Hints

Why should sorting happen before uniq?

uniq removes adjacent repeated lines. Sorting first brings equal directory strings together.

Summary

You built one normalized list by combining delimiter translation, sorting, duplicate removal, and redirection.

✨ Check Solution and Practice