Skip to main content
missing `--`, `[ -e ${REPLY%\~} ]` would be a problem for the file called `~`. Fixed a few typos and omissions. Use sh as $0. (not tested; but so wasn't the original :-)
Source Link
Stéphane Chazelas
  • 586.3k
  • 96
  • 1.1k
  • 1.7k

In zsh, you can use a glob qualifier to filter matches. The e modifier lets you specify arbitrary code; it's easier on the parsing to write a function and call it with the + modifier.

zsh -c 'deleted () {[[ ! [ -e ${REPLY%\~} ] };]]; ls -ld -- **/*~*\~(+deleted)' 

If zsh isn't available, you can use find.

find ~ -name '*~' -type f -exec sh -c '[ -e "${0%\~1%\~}" ] &&|| ls -ld "$0"'"$1"' \;sh {} ';' 

or, faster:

find ~ -name '*~' -type f -exec sh -c 'for x;f do [ -e "${x%\~f%\~}" ] &&|| ls -ld "$x"'"$f"; _done' sh {} + 

In zsh, you can use a glob qualifier to filter matches. The e modifier lets you specify arbitrary code; it's easier on the parsing to write a function and call it with the + modifier.

zsh -c 'deleted () { ! [ -e ${REPLY%\~} ] }; ls -ld **/*~(+deleted)' 

If zsh isn't available, you can use find.

find ~ -name '*~' -type f -exec sh -c '[ -e "${0%\~}" ] && ls -ld "$0"' \; 

or, faster:

find ~ -name '*~' -type f -exec sh -c 'for x; do [ -e "${x%\~}" ] && ls -ld "$x"' _ {} + 

In zsh, you can use a glob qualifier to filter matches. The e modifier lets you specify arbitrary code; it's easier on the parsing to write a function and call it with the + modifier.

zsh -c 'deleted() [[ ! -e ${REPLY%\~} ]]; ls -ld -- **/*\~(+deleted)' 

If zsh isn't available, you can use find.

find ~ -name '*~' -type f -exec sh -c '[ -e "${1%\~}" ] || ls -ld "$1"' sh {} ';' 

or, faster:

find ~ -name '*~' -type f -exec sh -c 'for f do [ -e "${f%\~}" ] || ls -ld "$f"; done' sh {} + 
Source Link
Gilles 'SO- stop being evil'
  • 865.9k
  • 205
  • 1.8k
  • 2.3k

In zsh, you can use a glob qualifier to filter matches. The e modifier lets you specify arbitrary code; it's easier on the parsing to write a function and call it with the + modifier.

zsh -c 'deleted () { ! [ -e ${REPLY%\~} ] }; ls -ld **/*~(+deleted)' 

If zsh isn't available, you can use find.

find ~ -name '*~' -type f -exec sh -c '[ -e "${0%\~}" ] && ls -ld "$0"' \; 

or, faster:

find ~ -name '*~' -type f -exec sh -c 'for x; do [ -e "${x%\~}" ] && ls -ld "$x"' _ {} +