Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question
add comment

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)

share|improve this answer
    
i see. thank you –  bks May 18 '10 at 11:49
add comment

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

ls | uniq -s 6

or

ls | uniq --skip-chars=6
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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