i have a list of files in a folder. the list of files is displayed using:

ls

now, i want to pipe that to uniq so it'll ignore the first 6 charactes before comparing.
is it possible? or perhaps i need to use another command?
thank you

link|improve this question

feedback

2 Answers

up vote 2 down vote accepted

pipe the output of ls first to sed to strip away the first X characters and then pipe it to uniq.

% ls | sed -e 's/.\{X\}//' | uniq

(note: replace X with 6 in your case)

link|improve this answer
i see. thank you – bks May 18 '10 at 11:49
feedback

Use the -s (--skip-chars) option if your version of uniq has it.

ls | uniq -s 6

or

ls | uniq --skip-chars=6
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.