Write a script named killdup. The script sorts all the lines in a file supplied to it as the first argument, and removes duplicate lines. The script stores the resulting output in a file whose name is given by the second argument.
I know how to sort it, but how to use the file as argument and then pass it to another file, which is also an argument.
sort -n | uniq -u | sort -n
alex05
0
Newbie Poster
Recommended Answers
Jump to PostThis awk one-liner works pretty well -
awk '!x[$0]++' file.old > file.new
This checks the whole line
This one just checks for part of the line in this case the first 16 characters.
awk '!x[substr($0,1,16)]++' file.old > file.new
All 2 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.