User Tools

Site Tools


bash:files:delete_duplicate_lines_from_a_files

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

bash:files:delete_duplicate_lines_from_a_files [2022/06/13 11:28] – created peterbash:files:delete_duplicate_lines_from_a_files [2022/06/13 11:29] (current) – removed peter
Line 1: Line 1:
-====== BASH - Files - Delete Duplicate Lines from Files ====== 
- 
-<code bash> 
-#! /bin/sh 
- 
-echo -n "Enter Filename-> " 
-read filename 
-if [ -f "$filename" ]; then 
-sort $filename | uniq | tee sorted.txt 
-else 
-echo "No $filename in $pwd...try again" 
-fi 
- 
-exit 0 
-</code> 
- 
-<WRAP info> 
-**NOTE:**  The above script goes line by line through your file and removes any duplicate line. 
- 
-It then places the new content into a new file and keeps the original file intact. 
-</WRAP> 
  
bash/files/delete_duplicate_lines_from_a_files.1655119685.txt.gz · Last modified: 2022/06/13 11:28 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki