0

I have a couple of tar archives, among them, some have the same filename as folders:

folderA
folderA.tar
folderB.tar
...

I want to be able to list/find all the tar files (ideally on the same/current folder) that don't already exist as folders (as in, folders with same names as tar archives).

In the above example, only folderB.tar would the only one showed.

How can i do the above using Bash/Unix tools? (ideally without using more than once instance of find/find-like utilities)

2

pure bash:

for line in *.tar;do [ -d "${line%.tar}" ] || echo $line;done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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