Talk:Remove duplicate elements: Difference between revisions
→Bash
(moving misplaced comment from Rosetta Code talk:General disclaimer) |
(→Bash) |
||
Line 15:
Does anybody know how to do it with Bash (or any other shell)?
for example, if I start with "-I/usr/include -I/usr/include -I/usr/other" I would like to get "-I/usr/include -I/usr/other"
: sort -u will take a line delimited list and eliminate non-unique lines. The trick for your example is that you have everything on one line. But you can use fmt to split lines and xargs to reassemble them:
$ echo -I/usr/include -I/usr/include -I/usr/other | fmt -sw1 | sort -u | xargs echo
-I/usr/include -I/usr/other
== APL ==
|