tag:blogger.com,1999:blog-7966727725512849871.post6597603662288250830..comments2023-05-29T09:27:13.597-04:00Comments on Victor's Blog: How to remove repeated lines in a file without changing the orderVictorhttp://www.blogger.com/profile/04337112644900142867noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-7966727725512849871.post-90707268247899537382012-02-11T17:20:44.751-05:002012-02-11T17:20:44.751-05:00The standard way to do this, at least for old time...The standard way to do this, at least for old timers is<br /><br />awk '!s[$0]++'Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7966727725512849871.post-61887154308266585642011-09-08T13:34:47.088-04:002011-09-08T13:34:47.088-04:00Just one small thing, the sed [0-9] bit won't ...Just one small thing, the sed [0-9] bit won't just remove the line numbers at the start, it will remove all numbers anywhere in each line.<br /><br />sed 's/^ *[0-9]*//g'<br /><br />worked for me without trashing the rest of the line.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7966727725512849871.post-19658409821193859122011-01-09T01:09:16.628-05:002011-01-09T01:09:16.628-05:00Many thanks.Many thanks.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7966727725512849871.post-18632278186699414422010-08-30T03:46:20.411-04:002010-08-30T03:46:20.411-04:00thanks for the interesting informationthanks for the interesting informationAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-7966727725512849871.post-86334413727316662372009-11-01T12:25:46.457-05:002009-11-01T12:25:46.457-05:00Great, sort of what I was looking for, I just have...Great, sort of what I was looking for, I just have a problem.<br />I need the same action but with an array.<br />If I have, for example:<br /><b>array=(1 2 3 4 1 2 3 4 1 2 3 4)</b><br />and I want to create a list for every "unique" value on that array.<br />I tried this to no avail:<br /><b>array2=( `echo ${array[@]} | sort | uniq -u` )</b><br />It doesn't work of course because the array values are printed all in a single line.<br />Do you have an idea of how can I achieve this? I'd prefer it to be on the fly and not saving it to a file and reading from it later...<br />Thanks in advanceTuxSaxhttps://www.blogger.com/profile/17448356414408001672noreply@blogger.com