Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
sed 's/$/\./' /input/file |grep -vf - /input/file
/etc
/root
/var
/home/
$ cat directory_list
/etc
/root
/var/adm
/var/tmp
/var
/home/
/home/test
/test/1/2/3
/test/1/2/
/test/1/2/3/4
/test/1
$ sed 's|^/|-|1;s|/.*||g;s|^-|/|1' directory_list | sort | uniq
/etc
/home
/root
/test
/var
$
/etc
/root
/var
/home/
/test/1
sed '/\/$/!s,$,/,' directory_list | sort | awk '!p||substr($0,1,length(p))!=p{p=$0;sub(/\/$/,"");print}'
$ cat directory_list
/etc
/root
/var/adm
/var/tmp
/var
/home/
/home/test
/test/1/2/3
/test/1/2/
/test/1/2/3/4
/test/1
$ sed '/\/$/!s,$,/,' directory_list | sort | awk '!p||substr($0,1,length(p))!=p{p=$0;sub(/\/$/,"");print}'
/etc
/home/
/home/test
/root
/test/1
/var
$
You mean at the end of lines ? Then let us change the Sed code abit :w5000 said:only a trailing space can "cheat" a bit.
sed 's,/* *$,/,' directory_list | sort | awk '!p||substr($0,1,length(p))!=p{p=$0;sub(/\/$/,"");print}'